Archive · Linux

Processes: ps, top and Signals

See what is running, find what is eating the CPU, and stop a process the right way.

1 min read

  • Ubuntu 18.04.2 LTS
  • procps-ng 3.3.12

A process is a running program with a PID. ps takes a snapshot; top updates live.

ps aux --sort=-%mem | head     # biggest memory users
ps -ef | grep nginx            # find a process (the grep shows itself too)
top                            # press P for CPU, M for memory, q to quit
pgrep -a sshd                  # PIDs and command lines by name

Stop processes with signals, politely first:

Command Signal Effect
kill PID SIGTERM (15) Ask the process to exit and clean up
kill -HUP PID SIGHUP (1) Many daemons reload configuration
kill -9 PID SIGKILL (9) Kernel ends it at once, no cleanup

Use -9 only when TERM is ignored; it can leave lock files and half-written data. nice -n 10 command and renice lower a job’s priority so it does not starve interactive work.