Master Linux Process Management: ps, Signals, Priorities & Job Control
This guide explains how to inspect and control Linux processes using the ps and top commands, explores process creation, termination, signals, priority adjustment, the /proc filesystem, and job control techniques for background and foreground execution.
1. The ps Command
Processes are programs running on your system, each identified by a unique Process ID (PID) assigned sequentially by the kernel. Running ps displays a snapshot of active processes:
ubuntu@ubuntu:~$ ps
PID TTY TIME CMD
3309 pts/1 00:00:00 bash
3794 pts/1 00:00:00 psPID – Process ID
TTY – Controlling terminal
TIME – Cumulative CPU time
CMD – Executable name
The manual page lists many options; a common usage is ps aux, which shows detailed columns such as USER, %CPU, %MEM, VSZ, RSS, STAT, START, TIME, and COMMAND.
2. Process Details
A process is an instance of a program that the kernel loads into memory, allocates CPU and I/O resources, and monitors. For example, running ps aux | grep cat reveals two separate cat processes even though they invoke the same binary.
3. Process Creation
New processes are created with the fork() system call, which clones the calling process and assigns a new PID. The child can continue executing the same program or replace its image with execve(). The original process becomes the parent, identified by PPID.
Using ps l shows a long format that includes the PPID column.
4. Process Termination
Processes exit via the _exit system call, returning a status code (0 for success). The parent must call wait() to reap the child’s exit status. Unreaped children become zombie processes , while children whose parents die first become orphan processes and are adopted by the init process (PID 1).
5. Signals
Signals are asynchronous notifications sent to a process to indicate events such as user interrupts, hardware faults, or inter‑process communication. Common signals include:
SIGHUP (1) – Hangup
SIGINT (2) – Interrupt (Ctrl‑C)
SIGKILL (9) – Forceful kill (cannot be caught)
SIGTERM (15) – Graceful termination
SIGSTOP – Stop execution
Processes can ignore, catch, block, or terminate in response to signals.
6. The kill Command
Use kill PID to send the default SIGTERM to a process, or specify a signal explicitly, e.g., kill -9 12345 to send SIGKILL.
7. Process Priority
CPU time is allocated in time slices. The scheduler can be nudged using nice (to start a process with a lower priority) and renice (to change the priority of an existing process):
nice -n 5 apt upgrade
renice 10 -p 3245Lower nice values mean higher priority; negative values increase priority further.
8. Process States
The STAT column of ps aux shows process states:
R – Running or runnable
S – Interruptible sleep
D – Uninterruptible sleep (usually I/O)
Z – Zombie (awaiting parent reap)
T – Stopped (e.g., by SIGSTOP)
9. The /proc Filesystem
Linux represents processes as directories under /proc, each named by its PID. Inside, files such as status, cmdline, and fd provide detailed information beyond what ps shows.
10. Job Control
Appending & to a command runs it in the background. Use jobs to list background jobs, fg %1 to bring a job to the foreground, and bg %1 to resume a stopped job in the background.
Liangxu Linux
Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
