Which is the command to find top 10 memory consuming process in Linux? If you want to find top CPU consuming process in Linux or display top 10 processes in descending order in Linux, here is the command to display processes with highest memory usage.
Ubuntu users can easily see running processes in Linux Terminal using ps command. The ps reports a snapshot of the current processes. ps displays information about a selection of the active processes. It is slighyly different from top command. top command is used when you want a repetitive update of the selection and the displayed information.
ps command displays the process ID (pid=PID), the terminal associated with the process (tname=TTY), the cumulated CPU time in [DD-]hh:mm:ss format (time=TIME), and the executable name (ucmd=CMD).
By default, the display output is unsorted, but can be sorted using –sort options in recursive manner.
Command To Find Top 10 Memory Consuming Process In Linux
The ps command can be mixed with various options to show the list of top processes sorted by RAM and CPU usage. Run the following command in Terminal to see the top running processes by RAM and CPU usage:
$ ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%mem | head
Below is the screenshot of the command output:
Explaining the command and all the options users:
- -A Select all processes. Identical to -e.
- -e Select all processes. Identical to -A.
- -o User-defined format. Option of ps allows to specify the output format. Format is a single argument in the form of a blank-separated or comma-separated list, which offers a way to specify individual output columns.
- –pid pidlist process ID. Identical to -p and p.
- –ppid pidlist parent process ID. This selects the processes with a parent process ID in pidlist. That is, it selects processes that are children of those listed in pidlist.
- –sort Specify sorting order.
- cmd simple name of executable
- %cpu CPU utilization of the process in “##.#” format. Currently, it is the CPU time used divided by the time the process has been running (cputime/realtime ratio), expressed as a percentage.
- %mem Ratio of the process’s resident set size to the physical memory on the machine, expressed as a percentage.
Command To Find Top 10 CPU Consuming Process In Linux
Similarly you can also print the top 10 CPU consuming processes. Run the following command given below:
ps -eo pid,comm,%cpu | sort -rk 3 | head
List Top 10 CPU & Memory Consuming Processes
Run the following command to list top 10 CPU and Memory consuming processes:
ps axo ruser,%mem,comm,pid,euser | sort -nr | head -n 10
ps displays information about a selection of the active processes.