EMZETT.
Login

Processes and signals: ps, top and kill

In short: Every running program is a process with a number (PID). With ps and top you see them, with signals you control or end them.

Viewing processes

ps aux                  # all processes with user, CPU, memory
ps aux | grep firefox   # find certain processes
top                     # live overview (q quits)
htop                    # more comfortable variant, if installed
pgrep -a nginx          # PIDs by name

In top, %CPU and %MEM show the load. A process has a state, for example R running, S waiting, Z zombie (finished but not yet collected).

Signals

With kill you send a signal to a process:

  • kill PID or kill -15 PID (SIGTERM): polite request to end. The program can clean up.
  • kill -9 PID (SIGKILL): immediate end by the kernel, no clean-up. Only if needed.
  • kill -HUP PID: many services reread their settings.
  • Ctrl+C in the terminal sends SIGINT, Ctrl+Z stops the process.
  • killall name and pkill name act by name.

Foreground and background

command & starts in the background, jobs lists, fg brings it back. For long runners tmux and screen or a service under systemd is suitable.

See also: Memory management and the OOM killer