The following command will show the list of top processes ordered by RAM and CPU use in descendant form (remove the pipeline and head if you want to see the full list):

# ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%mem | head

 

Sample Output
----------------------------------------------------------------
PID  	PPID 	CMD                      	%MEM 	%CPU
2591 2113 /usr/lib/firefox/firefox 7.3 43.5 2549 2520 /usr/lib/virtualbox/Virtual 3.4 8.2 2288 1 /home/gacanepa/.dropbox-dis 1.4 0.3 1889 1543 c:\TeamViewer\TeamViewer.ex 1.0 0.2 2113 1801 /usr/bin/cinnamon 0.9 3.5 2254 2252 python /usr/bin/linuxmint/m 0.3 0.0 2245 1801 nautilus -n 0.3 0.1 1645 1595 /usr/bin/X :0 -audit 0 -aut 0.3 2.5

 

The -o (or –format) option of ps allows you to specify the output format. A favourite of mine is to show the processes’ PIDs (pid), PPIDs (pid), the name of the executable file associated with the process (cmd), and the RAM and CPU utilization (%mem and %cpu, respectively).

 

Additionally, I use --sort to sort by either %mem or %cpu. By default, the output will be sorted in ascendant form, but personally, I prefer to reverse that order by adding a minus sign in front of the sort criteria.

 

To add other fields to the output, or change the sort criteria, refer to the OUTPUT FORMAT CONTROL section in the man page of ps command.

Hjälpte svaret dig? 0 användare blev hjälpta av detta svar (0 Antal röster)