Tools › Cheat sheets › System Administration › Processes & performance
📊

Processes & performance cheat sheet

Find what is using CPU and memory, and control running processes. Use signals gently: SIGTERM (15) first, SIGKILL (9) only as a last resort.

Click any command to copy it.

Inspect

CommandWhat it does
ps auxAll processes with user, CPU and memory.
ps -ef --forestProcesses as a parent/child tree.
ps aux --sort=-%mem | headTop memory users.
ps aux --sort=-%cpu | headTop CPU users.
pgrep -a nameFind processes by name, showing the command line.
topLive view of processes (press q to quit).
htopFriendlier live view (install htop).
uptimeLoad averages for 1, 5 and 15 minutes.

Signal and stop

CommandWhat it does
kill PIDAsk a process to terminate (SIGTERM).
kill -9 PIDDestructive: Force-kill a process immediately; it cannot clean up.
kill -HUP PIDAsk a daemon to reload its configuration.
pkill nameTerminate processes by name.
killall nameTerminate all processes with an exact name.
kill -lList available signals.

Priority and limits

CommandWhat it does
nice -n 10 commandStart a command with lower priority.
renice -n 5 -p PIDChange the priority of a running process.
ulimit -nShow the open file limit for the shell.
ulimit -aShow all limits.

Memory and system load

CommandWhat it does
free -hMemory and swap usage.
vmstat 1Memory, swap, I/O and CPU every second.
watch -n 2 'command'Repeat a command every 2 seconds.
dmesg -T | tailRecent kernel messages with readable timestamps, such as OOM kills.
sudo dmesg -T | grep -i 'out of memory'Check whether the OOM killer terminated something.

Debug a process

CommandWhat it does
sudo lsof -p PIDFiles and sockets a process has open.
sudo strace -p PIDTrace the system calls of a running process.
sudo ss -tp | grep PIDNetwork connections owned by a process.
ls -l /proc/PID/exeWhich binary a process is running.

Frequently asked questions

What is the difference between kill and kill -9?

kill sends SIGTERM, which lets the process shut down cleanly. kill -9 sends SIGKILL, which cannot be caught, so open files and locks may be left in a bad state.

What does load average mean?

The average number of processes running or waiting. A load roughly equal to the number of CPU cores means the system is fully busy.

More System Administration cheat sheets

⚙️ systemctl📜 journalctl📦 apt🎩 dnf / yum👥 Users & groups💽 Disks & storage🔄 rsync⏱️ Cron expressionsAll System Administration cheat sheets →
Copied to clipboard