Understand how Linux manages running programs: inspect processes with ps and top, control CPU priority with nice and renice, send signals with kill, manage foreground and background jobs, and keep processes running after logout with nohup.
A process is a program in execution. When you run ls, the kernel creates a new process — allocates memory, assigns a Process ID (PID), loads the program code, and begins executing it. When ls finishes, the process exits and releases its resources.
Every process has a parent (PPID). The first process is systemd (PID 1) — it starts all other processes on the system. This creates a process tree: systemd spawns your shell, your shell spawns the commands you run, and so on.
Key process attributes: PID (unique identifier), PPID (parent PID), UID/GID (owner), state (running/sleeping/zombie), priority (nice value), memory usage (VSZ/RSS), and CPU time consumed.
The Linux scheduler uses "nice values" to determine relative CPU priority. The range is -20 (highest priority, most CPU) to +19 (lowest priority, least CPU). The default for new processes is 0.
Only root can set negative nice values (increase priority). Any user can make their own processes nicer (decrease priority). The name comes from "being nice" to other users by not hogging CPU.
Signals are software interrupts sent to processes to notify them of events or request actions. The kill command sends signals — despite its name, it can send any signal, not just termination signals.
| Signal | Number | Name | Description |
|---|---|---|---|
SIGHUP | 1 | Hangup | Reload config without restart. Used for daemons: kill -1 PID |
SIGINT | 2 | Interrupt | Ctrl+C — polite termination request. Process can catch and handle. |
SIGTERM | 15 | Terminate | Default kill signal. Polite — allows cleanup. Process can catch. |
SIGKILL | 9 | Kill | Immediate, forced termination. Cannot be caught or ignored. Use as last resort. |
SIGSTOP | 19 | Stop | Pause (freeze) a process. Cannot be caught or ignored. |
SIGCONT | 18 | Continue | Resume a stopped process. |
A foreground job occupies your terminal — you must wait for it to complete before typing another command. Use Ctrl+C to terminate it or Ctrl+Z to suspend it.
A background job runs without occupying the terminal. Append & to run it in background from the start, or use bg after suspending with Ctrl+Z.
Malware often attempts to hide by manipulating process names, using kernel modules to remove themselves from process listings, or creating processes with names identical to legitimate system processes. When investigating a suspected compromise, use multiple methods: ps aux, ls /proc/ (each PID directory is a running process), lsof -p PID (open files), and compare the counts. A discrepancy between ps output and /proc/ directory entries is a rootkit indicator. Zombie processes in large numbers indicate a buggy parent process failing to reap children — not a security concern but worth investigating.