Bash List Processes

top opens a continuously updating, interactive view of running processes and overall system load, making it the standard tool for live monitoring.

Launching top

Typing top and pressing enter takes over the terminal with a live display that refreshes every few seconds by default. The screen is split between a system-wide header and a scrolling table of the busiest processes, sorted by CPU usage unless you change it.

top Output

$ top
top - 10:32:01 up 4 days,  2:15,  2 users,  load average: 0.42, 0.38, 0.31
Tasks: 148 total,   2 running, 145 sleeping,   0 stopped,   1 zombie
%Cpu(s):  6.3 us,  2.1 sy,  0.0 ni, 91.0 id,  0.4 wa
MiB Mem :   7854.0 total,   1204.3 free,   2938.1 used,   3711.6 buff/cache

  PID USER      PR  NI    VIRT    RES  %CPU  %MEM     TIME+ COMMAND
 3305 alice     20   0  812340  65200  12.3   0.8   3:41.02 node
 1188 root      20   0   55344   9100   0.3   0.1   0:02.10 nginx

Reading the Header

The load average shows three numbers: the average number of processes wanting CPU time over the last 1, 5, and 15 minutes. The Tasks line counts how many processes are running, sleeping, stopped, or zombied. The %Cpu(s) line breaks CPU time into user (us), system (sy), niced (ni), and idle (id) percentages, and the memory lines show how much RAM is free, used, and held in the disk cache.

Interactive Commands Inside top

top isn't just a display, it accepts single-key commands while it's running. Press P to sort by CPU usage, M to sort by memory usage, u to filter by a specific user, k to kill a process by PID, and q to quit back to your shell.

  • P — sort the process list by %CPU (the default)
  • M — sort the process list by %MEM
  • u — prompt for a username and show only that user's processes
  • k — prompt for a PID, then a signal number, and send it
  • r — renice a process, changing its scheduling priority
  • q — quit top and return to the shell

Killing From Inside top

$ top
(press k)
PID to signal/kill [default pid = 3305] 3305
Signal [default 15] 9
Note: If it's installed, htop is a friendlier alternative with color, mouse support, and easier scrolling, but top ships by default on virtually every Linux system, which makes it the one you can always rely on.
Note: Because top's list re-sorts every refresh, a PID's position on screen can shift right before you act on it. Always double-check the PID number itself, ideally cross-referenced with ps, before killing anything from inside top.