View process statistics in realtime

top
A simple but effective replacement for ps aux. I used to waste my time running ps over and over; top is the way to go. It also allows complex sorting options. Press q to exit "nicely" (Ctrl + C is always an option, of course). Note that the list updates each second, resorting in the process; if you're trying to grab a specific PID, you might be better off with ps. htop Alternatively, htop is available, though it may not come pre-installed. htop is slightly more interactive than top and includes color coding, visuals, and a nice interface for selecting and then killing processes. (Thanks to bwoodacre for this great tool.)
Sample Output
top - 18:53:03 up 103 days, 13:10,  1 user,  load average: 0.00, 0.00, 0.00
Tasks:  46 total,   1 running,  45 sleeping,   0 stopped,   0 zombie
Cpu(s):  0.0% us,  0.0% sy,  0.0% ni, 100.0% id,  0.0% wa,  0.0% hi,  0.0% si
Mem:   4032280k total,   572900k used,  3459380k free,        0k buffers
Swap:        0k total,        0k used,        0k free,        0k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
    1 root      16   0 10236  432  400 S    0  0.0   0:05.77 init
22204 root      15   0  5804  512  424 S    0  0.0   1:54.67 syslogd
24077 root      15   0 71696  712  664 S    0  0.0   0:00.00 cupsd
24565 root      15   0 55388  744  636 S    0  0.0   0:49.80 sshd
26154 root      16   0 21520  660  564 S    0  0.0   0:36.43 xinetd
26267 root      16   0 34164  516  464 S    0  0.0   0:00.00 couriertcpd
26271 root      17   0 26856  952  892 S    0  0.0   0:00.00 courierlogger
26283 root      21   0 34164  448  444 S    0  0.0   0:00.00 couriertcpd
26285 root      18   0 26724  740  736 S    0  0.0   0:00.00 courierlogger
26308 root      16   0 34164  516  464 S    0  0.0   0:03.94 couriertcpd
26311 root      16   0 26852  952  892 S    0  0.0   0:02.00 courierlogger
26329 root      21   0 34164  448  444 S    0  0.0   0:00.00 couriertcpd
26331 root      18   0 26720  740  736 S    0  0.0   0:00.00 courierlogger
 1800 named     15   0  140m 3556 1788 S    0  0.1   0:00.12 named
 5261 root      17   0 10648  648  428 S    0  0.0   0:00.00 mysqld_safe
 5423 mysql     16   0  221m  26m 5096 S    0  0.7  21:05.92 mysqld
 6129 root      16   0  112m 6300 3324 S    0  0.2   0:00.27 httpsd

-5
By: Zenexer
2009-03-18 00:03:42

What Others Think

top is good. These days (under linux) I like htop more.
bwoodacre · 500 weeks and 4 days ago
Top has a nifty bunch of commands. Type "?" to see the list. "c" toggles command / command line (fu++ :-)
mpb · 500 weeks and 4 days ago
I love that alternative, bwoodacre; I just yum'd it. I'm going to edit it into the description. I doubt I'll ever type "top" again. ;)
Zenexer · 500 weeks and 4 days ago
Try htop also.
waltharius · 500 weeks and 3 days ago
waltharius: Yes, that's listed as an alternative. Many Linux systems do not have htop/vtop installed by default, however.
Zenexer · 500 weeks and 3 days ago
Top doesn't always cut it for me. I find myself using 'ps' and 'pstree' a lot (with various options that depend on what I'm looking for. If I'm in Slackware, I sometimes use 'socklist'...a similar command in the BSD world is 'sockstat'.
unixmonkey11373 · 426 weeks and 2 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: