Many times you may need to check which process is consuming more memory or find top memory consuming process in Linux. If you don’t keep an eye on the most cpu intensive processes, they will slow down your system and even cause it to run our memory. So it is important to find out which processes consume most cpu and memory on your system. Here is how to find top cpu consuming process in Linux. You can use it to find out which process consumes most memory in Linux.
How to Find Top CPU Consuming Process in Linux
There are multiple ways to list top memory consuming processes in Linux.
Using top
top command will directly list all processes on your system, in descending order of their cpu usage and memory consumption.
$ top
Here is a sample output
Please note, top will keep updating itself regularly until you stop it using Ctrl+c command. You can also use htop command for same output. The difference being that htop allows you to scroll vertically as well as horizontally, unlike top command.
Also read: How to Open port in Linux
Using ps
You can also use ps command to find out the top memory consuming processes. The following command will list the top processes sorted by their cpu usage and memory consumption.
# sudo ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%mem | head
Here is the sample output
PID PPID CMD %MEM %CPU 2391 2113 /usr/lib/chrome/chrome 5.3 47.5 2249 2520 /usr/lib/virtualbox/Virtual 4.4 4.2 2188 1 /home/feghnepa/.dropbox-dis 2.4 0.3 1989 1543 /usr/lib/python 2.0 0.2 2013 1801 /usr/bin/node 0.9 2.5 2154 2252 python /usr/bin/linuxmint/m 0.8 0.0 2235 1801 nautilus -n 0.5 0.1 1545 1595 /usr/bin/celery 0.3 2.5
Also read : How to Create Remote Git Repository
Let us look at the above command in detail
ps command lists all processes running on your system
- o – lets you specify output format. We specify that we want to see pid, ppid, command, memory usage and cpu usage
- –sort – sort the output my memory %. Since default sort order is ascending and we want to sort in descending order we add a ‘-‘ sign before the sort criteria.
As you can see it is easy to monitor the most cpu consuming processes on your linux system.