Viewing Processes
# Show all processes
ps aux
# Show process tree
ps auxf
pstree -p
# Interactive process viewer
top
htopKey Process Information
| Column | Meaning |
|---|---|
| PID | Process ID |
| USER | Process owner |
| %CPU | CPU usage percentage |
| %MEM | Memory usage percentage |
| VSZ | Virtual memory size |
| RSS | Physical memory (resident set) |
| STAT | Process state (S=sleeping, R=running, Z=zombie) |
Finding Specific Processes
# Find by name
pgrep -a nginx
pidof nginx
# Find by port
ss -tlnp | grep :80
lsof -i :80Sending Signals
# Graceful stop (SIGTERM)
kill PID
kill -15 PID
# Force kill (SIGKILL) — last resort
kill -9 PID
# Kill all processes by name
killall nginx
pkill -f "python app.py"
# Reload configuration (SIGHUP)
kill -HUP $(pidof nginx)Background Processes
# Run in background
./long-task.sh &
# Bring to foreground
fg
# List background jobs
jobs
# Keep running after logout
nohup ./long-task.sh > output.log 2>&1 &
# Or use tmux/screenProcess Priority
# Run with lower priority
nice -n 19 ./heavy-task.sh
# Change priority of running process
renice -n 10 -p PIDZombie Processes
Zombies are processes that finished but their parent has not read their exit status. They use no resources but consume a PID:
# Find zombies
ps aux | grep Z
# Fix: kill the parent process
kill -9 PARENT_PID