How does Linux process management work and what are the key commands for managing processes?
Linux process management involves controlling the lifecycle of programs running on a system. Every process has a unique PID (Process ID) and runs with specific user permissions.
Process States
Running (R): Process is actively using CPU. Sleeping (S): Waiting for an event (interruptible). Uninterruptible sleep (D): Waiting for I/O, cannot be killed. Stopped (T): Suspended via SIGSTOP or Ctrl+Z. Zombie (Z): Process completed but parent hasn’t read its exit status.
Key Process Management Commands
ps aux: List all running processes with CPU/memory usage. top or htop: Real-time process monitoring. pgrep nginx: Find process IDs by name. kill PID: Send SIGTERM (graceful shutdown). kill -9 PID: Force kill with SIGKILL. killall nginx: Kill all processes by name. nice -n 10 command: Start process with lower priority. renice -n 5 -p PID: Change priority of running process. nohup command &: Run command immune to hangups in background. jobs / fg / bg: Manage background jobs.
Process Signals
SIGTERM (15): Request graceful termination. SIGKILL (9): Force kill – cannot be caught or ignored. SIGHUP (1): Reload configuration, used by daemons. SIGINT (2): Interrupt from keyboard (Ctrl+C). SIGSTOP (19): Pause process. SIGCONT (18): Resume paused process.
systemd Service Management
systemctl start/stop/restart/status service: Manage services. systemctl enable/disable service: Control boot behavior. journalctl -u service -f: Stream service logs in real time. systemctl list-units –type=service: List all active services.