Vol. I · No. 46The command line sectionSat, 10 Oct 2026
Linux · process & service management

top

what is the machine doing right now

top is a live view of the system. The header gives the load, the CPU split and the memory in use; the table beneath lists processes, refreshed every few seconds and sorted so the one using the most CPU is at the top.

ps is a photograph; top is the live picture — the first thing to open when a machine feels slow.

Shows
Processes, live
refreshed every 3 seconds
Sorted by
CPU use
press M for memory
Quit
q
k kills a process by id
For scripts
top -b -n 1
one plain-text snapshot

At the terminal

Read the session first, then the notes: each numbered line in the output is answered by the note with the same number.

user@netflow — bashprocps
$ top -b -n 1 | head -10
1top - 10:42:07 up 12 days, 3:14, 2 users, load average: 0.42, 0.31, 0.27
Tasks: 214 total, 1 running, 213 sleeping, 0 stopped, 0 zombie
2%Cpu(s): 3.1 us, 1.0 sy, 0.0 ni, 95.6 id, 0.2 wa, 0.0 hi, 0.1 si, 0.0 st
3MiB Mem : 7941.2 total, 1203.5 free, 3120.8 used, 3616.9 buff/cache
MiB Swap: 2048.0 total, 2048.0 free, 0.0 used. 4490.1 avail Mem
 
4 PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
2231 www-data 20 0 412300 98412 12040 S 6.2 1.2 4:31.07 php-fpm
812 mysql 20 0 1789044 402116 18232 S 2.0 4.9 61:12.44 mysqld
1 root 20 0 168940 13212 8420 S 0.0 0.2 0:09.81 systemd
Illustrative session · names, sizes and dates are examples, and every address is from a documentation or private range
Reading the output

What the numbered lines are telling you

1
Uptime and load average

The three load figures are averages over 1, 5 and 15 minutes. Compare them with the number of CPU cores: a load of 4 is busy on two cores and idle on sixteen.

2
Where the CPU time is going

us is user programs, sy the kernel, id idle. wa is time spent waiting for disk — a high wa means the disk, not the processor, is the bottleneck.

3
Memory: read "avail", not "free"

Linux uses spare memory as disk cache, so free looks small on a healthy machine. "avail Mem" on the next line is what programs can still have.

4
One row per process

RES is the memory actually in use, %CPU is of one core, and S is the state: R running, S sleeping, Z zombie.

Switches

A switch changes how the command behaves. These are the ones used day to day; man top lists the rest. Single-letter switches can usually be joined, so -l -a may be written -la.

-b
Batch mode: print plain text instead of taking over the screen — for scripts and pipes.
-n NUM
Refresh NUM times, then exit.
-d SECS
Wait this many seconds between refreshes.
-u USER
Show only this user’s processes.
-p PID
Watch only the processes with these ids.
-H
Show individual threads instead of whole processes.

Variations worth knowing

The same tool, pointed at a narrower question. These four cover most of what it is reached for day to day.

top

The live view. Press M to sort by memory, P by CPU, 1 to show each core, q to quit.

top -u www-data

Shows only one user’s processes.

top -b -n 1 -o %MEM | head -15

A single snapshot sorted by memory, suitable for a script or a log.

top -p 812

Watches a single process by its id.

In cybersecurity

A process that has no business running usually gives itself away by what it consumes.

CPU pinned by an unknown process

A process using a whole core around the clock, under a web-server or service account, is the usual sign of a crypto-miner dropped through a vulnerable application.

Names can lie

The COMMAND column shows what the process chose to call itself. Check the real binary with "ls -l /proc/PID/exe" before trusting a familiar name.

Everyone can see everyone

By default any user can list all processes and their command lines. Secrets passed as arguments are visible here to every account.

Filed under

Process & service management

Read alongside