Useful commands for monitoring and troubleshooting on Linux

Ed Phillis

Here are some basic commands that I use frequently when monitoring or troubleshooting issues on Linux. Typically this involves checking if a process is running, terminating a process, finding out where disk space is being used, checking what's using memory and how much is available.

System uptime:


This command shows how long the system has been up since it was last booted, how many users are currently logged in and the average load on the CPU(s), for example:


08:28:43 up 14 days, 2:42, 1 user, load average: 0.02, 0.02, 0.00



There are a few common commands for working with system processes:


top, ps, pgrep, kill, pkill, killall, nice and renice


The Linux top command shows the running processes within your Linux environment that consume the most system resources.

pgrep allows you to search for a running process by name, for example

pgrep -a apache returns all apache process and the command line that the process is using:


885 /usr/sbin/apache2 -k start


The -u flag shows the processes running under the denoted user, e.g: pgrep -u root

kill is used to send signals to a process, most often to stop processes. The signals typically used are 15(SIGTERM - termination signal) and 9(SIGKILL - kill signal).

killall can be used with the name of the process, for example,


killall apache2


nice is used to change the priority of a process when it starts. Using nice wont effect a running process.

renice is used to change the priority of a running process. When the priority is changed with renice then the process is restarted.


renice -n {{niceness_value}} -p {{pid}}




The free command on its own shows the total amount of RAM, the RAM that is being used and is available and also the Swap space on the disk if it has been confugured and enabled. Free can be used with -m (mb) or -g (gb) to make the output more readable:


     total used free shared buff/cache available
Mem: 4039164 879264 2216144 66436 943756 2822512
Swap: 524284 183928 340356



Disk Usage:



ncdu doesnt come installed as standard but I've found it a really useful tool for finding out where disk spaced is being used on the file system, on ubuntu/debian install as root using


apt-get install ncdu


Working with log files:

To monitor a log file in real time, use tail -f name-of-log-file