Check Linux Process Memory Usage with PS Command

The ps (process status) command is used to provide information about the currently running processes, including their process identification numbers (PIDs), USER, TTY, %CPU, %MEM and command. Every process is assigned a unique ID the system that is called PID. Here USER is the username, under which a process is running.

The %CPU shows percentage (%) of cpu usage of process and %MEM shows percentage (%) of memory usage of each running process in the system.

PS command usage

A common and convenient way of using ps command to obtain complete information about the processes currently on the system as follows:

$ ps -aufx

Here -a option tells ps to list the processes of all users on the system rather than just those of the current user, -u and -f options tell ps to provide detailed and full information about each process. The -x option adds to the list processes that have no controlling terminal, such as daemon.

In this tutorial I will discuss how to use ps command in Linux to check memory the process usage.

Check the memory usage for all processes

The following ps command will display %MEM in 1st column, PID in 2nd column and command in 3rd column for all running processes on the system:

$ ps -eo pmem,pid,cmd | sort -k 1 -nr
3.9 3094 /usr/sbin/mysqld
2.1 1779 iscsiuio
2.0 5371 /home/btest/TopCMM/
1.4 15386 /usr/bin/php
1.0 14465 /usr/local/apache/bin/httpd -DSSL
0.8 14515 /usr/local/apache/bin/httpd -DSSL
0.7 14514 /usr/local/apache/bin/httpd -DSSL
0.7 14511 /usr/local/apache/bin/httpd -DSSL
0.3 31925 lfd - sleeping
0.3 15377 /usr/sbin/exim -bd -q60m
0.2 9527 tailwatchd
0.2 5577 /usr/bin/python -tt /usr/sbin/yum-updatesd
0.2 2934 /usr/sbin/named -u named

Top 5 processes by memory usage

To display top 5 processes by memory usage enter the following ps command from the terminal:

$ ps -eo pmem,pid,cmd | sort -k 1 -nr | head -5
3.5 3094 /usr/sbin/mysqld
2.1 1779 iscsiuio
2.0 5371 /home/btest/TopCMM/
1.4 15386 /usr/bin/php
1.0 14465 /usr/local/apache/bin/httpd -DSSL


In this short tutorial we learn two ps command to check memory usage of a running process in a Linux system. If you have any questions or feedback, feel free to leave a comment.

Read Also:

Leave a Comment