Linux Processes Cheat Sheet

Comprehensive Linux process inspection, control, scheduling, and backgrounding workflows.

View
StandardDetailedCompact
Export
Copy the compact sheet, download it, or print it.
Download
`D` dense toggle · `C` copy all

Process Inspection Basics

Find, list, and summarize running processes.

List processes with BSD format

Show all processes with user, CPU, memory, and command columns.

bashANYpsinspectlisting
bash
ps aux
Notes

Show all processes with user, CPU, memory, and command columns.

List processes with full format

Show all processes with PID, PPID, start time, and command.

bashANYpsinspectlisting
bash
ps -ef
Notes

Show all processes with PID, PPID, start time, and command.

List processes for a user

Filter processes by effective user and show full format.

bashANYpsuserfilter
bash
ps -u "$USER" -f
Notes

Filter processes by effective user and show full format.

Show one PID

Inspect a specific process by PID.

bashANYpspidfilter
bash
ps -p 1234 -f
Notes

Inspect a specific process by PID.

Show parent-child tree in ps

Render a process tree using ps output.

bashANYpstreehierarchy
bash
ps -ef --forest
Notes

Render a process tree using ps output.

Find PID by name

Return matching PIDs for a process name pattern.

bashANYpgreppidfind
bash
pgrep nginx
Notes

Return matching PIDs for a process name pattern.

Find process by full command line

Match against the full command line and print PID plus command.

bashANYpgrepfull-commandfind
bash
pgrep -af "python.*worker"
Notes

Match against the full command line and print PID plus command.

Find PID with pidof

List the PIDs of a program by executable name.

bashANYpidofpidfind
bash
pidof sshd
Notes

List the PIDs of a program by executable name.

Show process tree

Display process hierarchy with PIDs and arguments.

bashANYpstreetreehierarchy
bash
pstree -ap
Notes

Display process hierarchy with PIDs and arguments.

Custom ps columns

Build a custom process table and sort by CPU usage.

bashANYpscolumnssort
bash
ps -eo pid,ppid,user,%cpu,%mem,stat,start,time,cmd --sort=-%cpu
Notes

Build a custom process table and sort by CPU usage.

Show threads with ps

List lightweight processes or threads.

bashANYpsthreads
bash
ps -eLf | head
Notes

List lightweight processes or threads.

Find oldest matching process

Return the oldest matching PID.

bashANYpgrepoldest
bash
pgrep -o sshd
Notes

Return the oldest matching PID.

Find newest matching process

Return the newest matching PID.

bashANYpgrepnewest
bash
pgrep -n sshd
Notes

Return the newest matching PID.

Filtering and Sorting

Focus on exactly the processes you need.

Sort by CPU

Show the most CPU-intensive processes first.

bashANYpssortcpu
bash
ps -eo pid,comm,%cpu,%mem --sort=-%cpu | head
Notes

Show the most CPU-intensive processes first.

Sort by memory

Show the most memory-intensive processes first.

bashANYpssortmemory
bash
ps -eo pid,comm,%mem,rss,vsz --sort=-%mem | head
Notes

Show the most memory-intensive processes first.

Filter by TTY

Show processes attached to a terminal.

bashANYpsttyfilter
bash
ps -t pts/0 -f
Notes

Show processes attached to a terminal.

Filter by parent PID

List child processes of a specific parent.

bashANYpsppidfilter
bash
ps --ppid 1 -f
Notes

List child processes of a specific parent.

Find process owned by user

Limit matches to one or more users.

bashANYpgrepuserfilter
bash
pgrep -u www-data nginx
Notes

Limit matches to one or more users.

Find process by session

Match processes in a session ID.

bashANYpgrepsession
bash
pgrep -s 1234
Notes

Match processes in a session ID.

Find process by terminal

Match processes running on a specific terminal.

bashANYpgreptty
bash
pgrep -t pts/0
Notes

Match processes running on a specific terminal.

Filter by state

Find processes in a given state, here zombies.

bashANYpsstatezombie
bash
ps -e -o pid,stat,cmd | awk '$2 ~ /^Z/ {print}'
Notes

Find processes in a given state, here zombies.

Find process listening on port

Identify the process bound to a TCP port.

bashANYlsofportfind
bash
lsof -iTCP:8080 -sTCP:LISTEN -Pn
Notes

Identify the process bound to a TCP port.

Show process for listening sockets

List listening TCP sockets with process info.

bashANYsssocketprocess
bash
ss -lntp
Notes

List listening TCP sockets with process info.

Process Control and Signals

Terminate, pause, resume, and signal processes safely.

Send SIGTERM

Ask a process to terminate gracefully.

bashANYkillsignalterm
bash
kill 1234
Notes

Ask a process to terminate gracefully.

Force kill with SIGKILL

Immediately kill a process that is not responding.

bashANYkillsignalsigkill
bash
kill -9 1234
Notes

Immediately kill a process that is not responding.

Reload with SIGHUP

Commonly used to ask daemons to reload configuration.

bashANYkillsignalreload
bash
kill -HUP 1234
Notes

Commonly used to ask daemons to reload configuration.

Pause process with SIGSTOP

Suspend execution without terminating the process.

bashANYkillsignalstop
bash
kill -STOP 1234
Notes

Suspend execution without terminating the process.

Resume process with SIGCONT

Resume a stopped process.

bashANYkillsignalcontinue
bash
kill -CONT 1234
Notes

Resume a stopped process.

Signal by name

Signal all processes whose names match a pattern.

bashANYpkillsignalname
bash
pkill nginx
Notes

Signal all processes whose names match a pattern.

Signal by full command

Match against full command lines.

bashANYpkillsignalfull-command
bash
pkill -f "gunicorn: worker"
Notes

Match against full command lines.

Kill all processes for a user

Signal all processes owned by a user.

bashANYpkillusersignal
bash
pkill -u alice
Notes

Signal all processes owned by a user.

Kill all by executable name

Kill all processes that match an executable name.

bashANYkillallsignal
bash
killall node
Notes

Kill all processes that match an executable name.

List signal names

Print known signal names and numbers.

bashANYkillsignalsreference
bash
kill -l
Notes

Print known signal names and numbers.

Pipe pgrep into kill

Signal all matching PIDs found via pgrep.

bashANYpgrepxargskill
bash
pgrep -f "celery worker" | xargs kill -TERM
Notes

Signal all matching PIDs found via pgrep.

Kill process using a port

Kill the process that is using a TCP port.

bashANYfuserportkill
bash
fuser -k 8080/tcp
Notes

Kill the process that is using a TCP port.

Priority, Scheduling, and CPU Affinity

Adjust scheduling priority and pin workloads.

Start command with lower priority

Run a command with a niceness offset.

bashANYnicepriority
bash
nice -n 10 long-running-job
Notes

Run a command with a niceness offset.

Change process priority

Adjust niceness for an existing process.

bashANYrenicepriority
bash
renice 5 -p 1234
Notes

Adjust niceness for an existing process.

Show real-time scheduler

Inspect real-time scheduling policy and priority.

bashANYchrtscheduler
bash
chrt -p 1234
Notes

Inspect real-time scheduling policy and priority.

Set SCHED_FIFO policy

Assign a real-time FIFO scheduler to a process.

bashANYchrtschedulerrealtime
bash
sudo chrt -f -p 50 1234
Notes

Assign a real-time FIFO scheduler to a process.

Run command on selected CPUs

Pin a command to specific CPU cores.

bashANYtasksetcpu-affinity
bash
taskset -c 0,1 myserver
Notes

Pin a command to specific CPU cores.

Show or change affinity for PID

Inspect or update CPU affinity for an existing process.

bashANYtasksetcpu-affinity
bash
taskset -cp 0-3 1234
Notes

Inspect or update CPU affinity for an existing process.

Run with IO priority

Run a command with lower I/O priority.

bashANYioniceio-priority
bash
ionice -c2 -n7 updatedb
Notes

Run a command with lower I/O priority.

Change IO priority for PID

Set idle I/O scheduling for a running process.

bashANYioniceio-priority
bash
ionice -c3 -p 1234
Notes

Set idle I/O scheduling for a running process.

Set shell resource limit

Cap the number of user processes for the current shell.

bashANYulimitlimits
bash
ulimit -u 4096
Notes

Cap the number of user processes for the current shell.

Backgrounding and Daemonization

Keep commands running after you disconnect or background them safely.

Run command immune to hangups

Keep a process running after the shell exits.

bashANYnohupbackground
bash
nohup ./worker.sh > worker.log 2>&1 &
Notes

Keep a process running after the shell exits.

Start in a new session

Start a process in a new session detached from the terminal.

bashANYsetsidsession
bash
setsid ./server.sh
Notes

Start a process in a new session detached from the terminal.

Run inside screen

Use screen for a resumable terminal session.

bashANYscreenbackground
bash
screen -S myjob
Notes

Use screen for a resumable terminal session.

Run inside tmux

Use tmux for persistent terminal multiplexing.

bashANYtmuxbackground
bash
tmux new -s myjob
Notes

Use tmux for persistent terminal multiplexing.

Limit runtime with timeout

Terminate a command if it runs too long.

bashANYtimeoutcontrol
bash
timeout 30s ./script.sh
Notes

Terminate a command if it runs too long.

Measure elapsed time

Measure runtime of a command.

bashANYtimemeasurement
bash
time tar -czf backup.tgz /srv/data
Notes

Measure runtime of a command.

Repeat command with watch

Re-run a command periodically for live monitoring.

bashANYwatchmonitoring
bash
watch -n 2 "ps -eo pid,comm,%cpu --sort=-%cpu | head"
Notes

Re-run a command periodically for live monitoring.

Recommended next

No recommendations yet.