ps — Inspecting Processes
Bash
# Current session processes
ps
# All processes (BSD style)
ps aux
# All processes (Unix style)
ps -ef
# Search for a specific process
ps aux | grep nginx
# View as a tree
ps axjf
pstree -p
# Processes for a specific user
ps -u deploy
# Sort by CPU / memory
ps aux --sort=-%cpu | head -10
ps aux --sort=-%mem | head -10Key columns
| Column | Meaning |
|---|---|
| PID | Process ID |
| %CPU | CPU usage |
| %MEM | Memory usage |
| VSZ | Virtual memory size (KB) |
| RSS | Resident set size (KB) |
| STAT | State (S=sleeping, R=running, Z=zombie, D=I/O wait) |
kill — Sending Signals
Bash
# Default terminate (SIGTERM, 15 — graceful shutdown request)
kill 1234
# Force kill (SIGKILL, 9 — immediate termination)
kill -9 1234
kill -KILL 1234
# Kill by process name
pkill nginx
pkill -9 node
# Signal all matching processes
killall nginx
# List signals
kill -lCommonly used signals
| Signal | Number | Meaning |
|---|---|---|
| SIGTERM | 15 | Graceful shutdown request |
| SIGKILL | 9 | Force kill (cannot be ignored) |
| SIGHUP | 1 | Restart (reload configuration) |
| SIGSTOP | 19 | Pause |
| SIGCONT | 18 | Resume |
nice · renice — Adjusting Priority
nice value: -20 (highest priority) ~ +19 (lowest priority), default 0
Bash
# Run at lower priority (background work)
nice -n 10 tar czf backup.tar.gz /data
# Higher priority (requires root)
sudo nice -n -10 ./critical-process
# Change priority of a running process
renice -n 5 -p 1234 # By PID
renice -n 10 -u deploy # By user
# Check current priority
ps -o pid,ni,comm -p 1234htop — Interactive Monitoring
Bash
sudo apt install -y htop
htopKey shortcuts
| Key | Action |
|---|---|
| F2 | Setup |
| F3 / / | Search |
| F4 | Filter |
| F5 | Tree view |
| F6 | Select sort column |
| F9 | Send signal (kill) |
| F10 / q | Quit |
| Space | Tag process |
| u | Filter by user |
Managing Background Processes
Bash
# Run in background
./long-task.sh &
# Job list
jobs
# Bring to foreground
fg %1
# Send to background (after Ctrl+Z)
bg %1
# Keep running after terminal closes
nohup ./script.sh > output.log 2>&1 &
# Detach a running process
disown %1Editorial note
AI tools may assist drafting. Check the evidence in each guide for whether commands were run and which environment was used. Confirm the current docs for your version before applying instructions, and email us about errors. email us
Topic-related official docs (auto-linked · not per-claim sources)Linux man pages ↗
Questions & answers
Ask a question about this guide. We'll review and reply.