Every command you run in a terminal becomes a process. Understanding how to view running processes, send them signals, manage background jobs, and keep processes running after you disconnect is fundamental to working effectively on Linux systems — especially when managing servers.
Viewing processes with ps
ps snapshots the current process list. The aux flags show all processes from all users in a detailed format:
ps aux # All processes (user, PID, CPU%, MEM%, command)
ps aux | grep python # Find specific processes
ps -ef --forest # Process tree showing parent-child relationships
The PID (Process ID) column in ps output is what you need for the kill command. Get in the habit of verifying the PID before sending any signal.
Signaling processes with kill
Despite its name, kill doesn’t always kill processes — it sends signals. The two most common are SIGTERM (graceful shutdown) and SIGKILL (force kill):
kill PID # Send SIGTERM — ask process to shut down gracefully
kill -9 PID # Send SIGKILL — force kill immediately
killall process_name # Kill all processes with this name
pkill -f "pattern" # Kill processes matching a pattern
Always try
kill PID(SIGTERM) before resorting tokill -9. SIGTERM gives the process a chance to clean up — close files, release locks, save state. SIGKILL is the last resort when a process is truly unresponsive.
Job control: bg, fg, and &
The shell’s job control system lets you manage multiple processes within a single terminal session:
command & # Run command in the background immediately
Ctrl+Z # Suspend the current foreground process
jobs # List all background/suspended jobs
bg %1 # Resume job 1 in the background
fg %1 # Bring job 1 to the foreground
The typical workflow: start a long-running process, realize you need the terminal, press Ctrl+Z to suspend it, then bg to resume it in the background. No need to restart.
Persistent processes with nohup
When you close a terminal or disconnect from SSH, processes started in that session receive a SIGHUP signal and typically terminate. nohup prevents this:
nohup long-command & # Run even after terminal closes
nohup command > output.log 2>&1 & # With output redirection
For production workloads, tools like systemd, supervisor, or tmux/screen provide more robust process management than nohup. But for quick tasks — running a build overnight, keeping a dev server alive — nohup gets the job done.
Process management ties together everything else you do on the command line. When something isn’t working, the answer usually starts with ps aux | grep to see what’s actually running.
Ready to practice? Explore the project repository for the full process management reference and interactive exercises.