
watch — underrated Linux command
Many Linux users write small scripts to monitor system state — CPU usage, disk space, open connections, and more. But there is a much simpler tool built into most Linux systems: watch. It allows you to run any command repeatedly and see the output update in real time. Basic usage The syntax is simple: watch command By default, the command runs every 2 seconds. Example: monitoring the mail queue watch mailq This refreshes the list of outgoing messages every two seconds so you can see the mail queue shrink or grow in real time. Example: watching network connections watch ss -tuln This is useful when debugging network services or checking if a port becomes active. Example: monitoring processes watch "ps aux | grep nginx" This lets you observe whether a process starts, stops, or changes. Changing the interval You can change the refresh interval with -n . watch -n 1 mailq This runs the command every 1 second. Highlighting differences One of the most useful options is -d , which highlights c
Continue reading on Dev.to
Opens in a new tab



