Viewing Processes
# All processes with full details
ps aux
# Tree view (shows parent-child relationships)
ps auxf
# Filter by name
ps aux | grep nginx
# Real-time monitoring
top
htop # More user-friendly (install: apt install htop)Process Signals
# Graceful termination
kill PID
kill -SIGTERM PID
# Force kill (last resort)
kill -9 PID
kill -SIGKILL PID
# Kill all processes by name
killall nginx
pkill -f "python script.py"Background and Foreground
# Run in background
./long-script.sh &
# Move running process to background
# Press Ctrl+Z to suspend, then:
bg
# Bring back to foreground
fg
# List background jobs
jobsProcess Priority
# Run with lower priority (higher nice value = lower priority)
nice -n 19 ./heavy-task.sh
# Change priority of running process
renice -n 10 -p PIDPersistent Processes
Keep processes running after logout:
# Using nohup
nohup ./script.sh > output.log 2>&1 &
# Using screen
screen -S mysession
./long-running-task.sh
# Press Ctrl+A, D to detach
screen -r mysession # Reattach
# Using tmux
tmux new -s mysession
./long-running-task.sh
# Press Ctrl+B, D to detach
tmux attach -t mysession