Linux: Monitor Processes: top

By Xah Lee. Date: . Last updated: .

Linux top is a command line program that lets you monitor CPU usage.

linux top screenshot 2015-12-26
top

In terminal, type top. Then, try the following in order:

  1. z】 → toggle color.
  2. x】 → toggle coloring of sort column.
  3. s 9 9 Enter】 → set update frequency to every 99 seconds.
  4. Space】 → force a update.
  5. >】 → change the sort column to the right of current sort column.
  6. <】 → change the sort column to the left.
  7. R】 → toggel reverse sort order.
  8. O k Enter】 → order by CPU usage. (also 【P】)
  9. O n Enter】 → order by memory usage. (also 【M】)
  10. O a Enter】 → order by pid.
  11. O x Enter】 → order by process name.
  12. c】 → show full path of commands.
  13. k】 → kill a process by pid.
  14. u user】 → show only processes of a user.
  15. h】 → help.
  16. q】 → quit.

Summary Area

top - 12:59:21 up 20:59,  0 users,  load average: 1.05, 0.93, 0.90
      current     system                     past 1 min, 5 min, 15 min
      time        uptime

In general, “load average”/“number of cpu core” = CPU load. Higher than 1 means overloaded.

Tasks: 139 total,   1 running, 137 sleeping,   0 stopped,   1 zombie
Cpu(s):  5.4%us, 32.4%sy,  0.0%ni, 62.2%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
          user    system    niced     idle   IO wait
Mem:    800340k total,   652680k used,   147660k free,    45688k buffers
Swap:   818172k total,     8584k used,   809588k free,   315372k cached

Actual free memory (RAM) available to programs is: free + buffers + cached. For detail, see: Linux: Show Free Memory.

Better is to see memory usage visually. Use htop. [see Linux: Monitor Processes, “htop”]

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND

For some explanation of these, do man top.

Common Top Options

Better top: htop

unix “top” is a very old program. It has some problems. For example, sometimes you want to view one particular process, but if you don't have a long screen, it's very diffucult or impossible, unless you find the pid first than call top -p pid.

A much better one is “htop”. See Linux: Monitor Processes, “htop”.

Linux Shell Basics

  1. Get System Info
  2. Shell Basics
  3. grep, cat, awk, uniq
  4. sort
  5. find, xargs
  6. diff Files/Dir
  7. dir size: du
  8. dir tree
  9. tar gzip bzip2 xz 7zip rar zip
  10. wget, curl, GET, HEAD
  11. rsync
  12. Install Packages

Sys Admin

  1. Job Control
  2. ps
  3. top
  4. htop
  5. RAM stat
  6. Users and Groups
  7. File Permission
  8. Opened Files: lsof
  9. shutdown, sleep

Bash/Terminal

  1. Bash Keys, Terminal Keys, Man Page Keys
  2. Bash Prompt Setup
  3. Bash Color Prompt
  4. .bashrc, .profile, .bash_profile
  5. Virtual Console
  6. Terminal Control Sequence Keys
  7. Reset Terminal
  8. tmux
  9. man page
  10. Bash Manual in Chapters
  11. BASH Shell Misc Tips
  12. Log Terminal Session

Linux Desktop

  1. Most Useful GUI Apps
  2. Set Default App
  3. Shell Commands for GUI Apps
  4. Image Viewers
  5. Music Players
  6. Move File to Trash by Command
  7. X11 Selection and Clipboard
  8. How to Switch to LXDE, Xfce
  9. LXDE Keyboard Shortcuts
  10. LXDE/Openbox, Change Keyboard Shortcuts
  11. LXDE Set Key Repeat Rate
  12. LXDE/OpenBox, Disable Mouse Scroll Wheel Hide Window
  13. Xfce Keyboard Shortcuts
  14. Xfce Good Themes
  15. xmonad Keybinding
  16. How to Restart X11
  17. Why Tiling Window Manager Sucks
  18. Standard Fonts
  19. How to Install Font

If you have a question, put $5 at patreon and message me.