Linux tricks, one-liners & shell magic

#!/bin/vpp.dk

Community Linux tricks, one-liners & shell scripts — searchable & formatted.

Category: system-info — 7 trick(s)

+ Add a New Trick

Watch live bandwidth usage broken down by network interface using nload or ifstat.
bash
$ # Using nload (apt install nload): nload eth0 # Without extra tools — poll /proc/net/dev: watch -n 1 'cat /proc/net/dev | column -t'
Delete this trick? This cannot be undone.
Print every environment variable in alphabetical order — handy when debugging missing config or checking what a script will see.
bash
$ printenv | sort # Or just search for a specific one: printenv | grep -i path
Delete this trick? This cannot be undone.
List all systemd services and their current status on modern Linux systems.
bash
$ systemctl list-units --type=service --state=running # Full list including inactive: systemctl list-units --type=service
Delete this trick? This cannot be undone.
Stream new lines appended to a log file, useful for monitoring deployments or service output.
bash
$ tail -f /var/log/syslog # Follow multiple files at once: tail -f /var/log/nginx/access.log /var/log/nginx/error.log
Delete this trick? This cannot be undone.
Find which directories are eating your disk space, sorted from largest to smallest.
bash
$ du -sh /* 2>/dev/null | sort -rh | head -20 # Show only current directory depth 1: du -sh ./*/ | sort -rh
Delete this trick? This cannot be undone.
The watch command re-runs a command at a set interval and displays the output — great for monitoring.
bash
$ # Refresh every 2 seconds (default): watch df -h # Every 0.5 seconds, highlight differences: watch -n 0.5 -d 'free -m'
Delete this trick? This cannot be undone.
List all listening TCP/UDP ports and the process that owns them.
bash
$ # All listening sockets + process names: ss -tulnp # Or with netstat (older systems): netstat -tulnp # Check if a specific port is open: ss -tulnp | grep ':443'
Delete this trick? This cannot be undone.