Monitor Linux System Resources Using the Top Command

The top is a great command-line system resource-monitoring tool in the Linux system. It displays real-time information about the CPU processes, memory usage, processor activity, processes managed by the kernel, load average, and many more features. 

In this post, we will show how you can monitor the system resources of a Linux system in real-time behavior using the top command. The top command comes preinstalled in almost all Linux distributions.

Use of the Top Command 

By running the following command, you can launch the top command interface:

$ top

The following details displayed on the terminal screen related to each task or process:

PID – Unique process ID
User – User name who is using a task
PR – Task priority
NI – Nice value
Virt – Total virtual memory usage by a task
RES – RAM usage information of each process
SHR – Shared memory usage
%CPU – CPU usage
%MEM – Memory usage details of each process
TIME+ – total CPU time usage detail in hundredths of a second

To exit from the top command interface press ‘q’.

Monitoring System Resources Using top Command

You can display the statistics of different resources using the top utility:

To display a specific process, type `u` and then enter the user name as follows:

Or enter the following command to display all processes for a specific user:

$ top –u user-name

To kill a process using top utility, press `k` and type the process id, and hit Enter.

You can view all running processes using top utility by pressing `z` from the keyboard.

To sort the process according to the memory usage, press `M` or (shift+m). You will see all processes sorted in the biggest to the smallest memory usage order.

To sort processes according to the CPU usage, press P or (shift +p). To highlight that column the sorted column press `x`.

To view the full command path under the command column, press `c`. You will see the following output:

Conclusion

We have seen how to monitor the system resources usage using the top utility in a Linux system. The all above commands and shortcut key will help you in the future.

Leave a Reply

Your email address will not be published. Required fields are marked *