The problem
You need to monitor system processes, find resource hogs, or kill frozen applications.
The solution
# List all processes
ps aux
ps -ef
# Find process by name
pgrep firefox
ps aux | grep nginx
# Detailed process tree
pstree -p
# Interactive process viewer
top
htop # if installed
# Kill processes
kill PID # Graceful termination
kill -9 PID # Force kill
pkill process_name # Kill by name
killall process_name # Kill all instances
# Niceness (priority)
nice -n 10 command # Start with low priority
renice -n 5 -p PID # Change priority of running process
# Background/foreground
command & # Run in background
jobs # List background jobs
fg %1 # Bring job 1 to foreground
bg %2 # Continue job 2 in background
# Monitor resource usage
vmstat 1 # Virtual memory stats every second
iostat 2 # I/O statistics every 2 seconds
# Find open files by process
lsof -p PID
lsof -i :8080 # Find process using port 8080
# Signal processes
kill -HUP PID # Reload configuration (SIGHUP)
kill -USR1 PID # User-defined signalPut it to work
# Find and kill frozen Chrome process
ps aux | grep chrome
# Find PID from output
kill -9 12345
# Monitor CPU usage
top
# Press 'P' to sort by CPU, 'M' for memory
# Run long task in background
python script.py &
# Later: fg %1 to bring back
# Change priority of backup task
renice -n 19 -p 6789 # Lowest priorityWorth knowing
Signal 9 (SIGKILL) cannot be caught by process. Use SIGTERM (15) first for graceful shutdown.