How to Find Linux Process Memory Usage with PS Command

The ps or "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 username, under which user a process is running.

TTY stands for terminal type or teletype is the name of the console or terminal that the user logged into, which can also be found by using the tty command. This information is generally only useful on a multi-user network. %CPU shows percentage (%) of cpu usage of process and %MEM shows memory usage percentage(%) of process and command display running command for process.

PS command usage

# ps [options]

We use PS command with options, without any options it sends to standard output, which is the display monitor by default. A common and convenient way of using ps to obtain much more complete information about the processes currently on the system is to use as below:

# 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 tells 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.

Here we will discuss about how to use ps Command in Linux to find how much memory the process use.

Check the memory usage for all processes

It will display %MEM in first column, PID in second and Command in third for all running processes as below.

# 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 below command:

#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

Please let us know your suggestion on this article.

Read Also:

Bobbin Zachariah 9:01 am


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

All comments are subject to moderation.