Web Design

Categorized | cli, Hardware

Tags : , , ,

List Linux processes by CPU or Memory usage

You can use a one-string command in Linux to nicely display in CLI the processes that consume your CPU. Use

ps -e -o pcpu,cpu,nice,state,cputime,args –sort pcpu | sed ‘/^ 0.0 /d’

and you will get something like this:

%CPU CPU  NI S     TIME COMMAND
 0.1   -   0 S 00:00:13 metacity
 0.1   -   0 S 00:00:18 /usr/lib/thunderbird/thunderbird-bin
 0.2   -   0 S 00:00:29 /usr/bin/pulseaudio -D –log-target=syslog
 0.3   -   0 S 00:00:30 gnome-screensaver
 0.4   -   0 S 00:00:44 nautilus –no-desktop –browser
 0.5   -   0 S 00:00:54 gnome-panel
 0.6   -   0 S 00:01:04 mocp
 1.4   -   0 S 00:02:28 /sbin/mount.ntfs-3g /dev/sdb1 /media/Moviz -o rw,nosuid,nodev,uhelper=hal,locale=en_US.UTF-8
 2.2   -  -5 R 00:03:52 [events/0]
 2.9   -   0 S 00:04:56 transmission
 6.0   -   0 S 00:10:05 /usr/X11R6/bin/X :0 -br -audit 0 -auth /var/lib/gdm/:0.Xauth -nolisten tcp vt7
 8.9   -   0 S 00:14:35 /usr/lib/firefox-3.0.5/firefox

To display those processes that use the most memory, use this instead:

ps -e -orss=,args= | sort -b -k1,1n | pr -TW$COLUMNS

Author Profile

T4L ;

Other posts by

Author's web site



Are you satisfied with this blog?
Why not subscribe our RSS Feed? you will always get the latest post.


3 Comments

  1. FND

    I generally use top (or htop) – but this might come in handy too!

    1
  2. John

    htop, f6 function key and you get a lot of choices of how to sort including those you mentioned. Plus it is color coded. Also a lot less key strokes.

    2
  3. anonymous

    Thanks. I’ve wanted this for a while, but was too lazy to find the right combination of switches and sorting!

    3

1 Trackback(s)

  1. 03 01 2009 : CLI to show CPU usage in processes « Linux & Stuff

Leave A Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>