Operations 53 min read

Master Linux Process Management: Jobs, Signals, and Real‑Time Monitoring

This guide explains Linux process fundamentals, including process components, states, job control commands, signal handling, and monitoring tools like ps, top, and htop, with practical examples and step‑by‑step demonstrations for managing foreground and background jobs.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
Master Linux Process Management: Jobs, Signals, and Real‑Time Monitoring

1. Process Overview

A process is a running instance of an executable program. Each process has a unique PID and its attributes are stored under /proc/<PID>. The PID is never reused while the process exists.

1.1 Process Components

Allocated memory address space

Security attributes (ownership and privileges)

One or more execution threads

Process state

1.2 Process Environment

Local and global variables

Current scheduling context

Allocated system resources such as file descriptors and network ports

1.3 Process Creation

When a parent process calls fork(), the kernel creates a child process with a new PID while copying the parent’s address space. The child inherits the parent’s UID, GID, and resource limits. The child can then replace its image with exec() to run a different program. If a child exits before the parent reaps it, the kernel keeps a zombie entry until the parent calls wait().

1.4 Process Classification

Foreground (interactive) processes are attached to a terminal and receive input.

Daemon (background) processes run without a controlling terminal; they can be detached further with nohup … &.

2. Process States

Linux defines several process states, each represented by a single‑letter code shown by ps: R – Running or runnable (on the run queue). S – Interruptible sleep (waiting for an event). D – Uninterruptible sleep (usually I/O). T – Stopped (by job control or signal). Z – Zombie (terminated but not reaped). X – Dead (should not appear in normal output).

3. Common Process‑Related Commands

3.1 Listing Processes

ps aux          # show all processes with detailed info
ps -ef          # BSD‑style full‑format listing
ps -eo pid,comm,ni   # show PID, command name, and nice value only

3.2 Filtering and Searching

pgrep sleep          # list PIDs of processes whose name matches "sleep"
pidof sleep          # show PID(s) of "sleep" processes

3.3 Process Tree

pstree               # display the hierarchical process tree

3.4 Memory and I/O Statistics

vmstat               # show virtual memory, swap, I/O, and CPU stats
free -h              # display free and used memory

4. Job Control (Shell)

Job control lets a single shell manage multiple commands. Each pipeline forms a job, and all processes in the pipeline belong to the same process group. jobs – list current jobs and their status. bg %n – resume stopped job %n in the background. fg %n – bring job %n to the foreground. kill %n – send a signal to job %n (default SIGTERM). Ctrl+Z – suspend the foreground job. Ctrl+C – send SIGINT to the foreground job.

Example of creating three background jobs that continuously append words to ~/outfile:

(while true; do echo -n 'rock ' >> ~/outfile; sleep 1; done) &
(while true; do echo -n 'paper ' >> ~/outfile; sleep 1; done) &
(while true; do echo -n 'scissors ' >> ~/outfile; sleep 1; done) &

Use jobs to see their status, fg %1 to bring the first job to the foreground, and Ctrl+Z to stop it again. bg %1 resumes it in the background. kill %2 terminates the second job.

5. Signals

Signals are software interrupts that inform a process of events. Common signals used for process management: SIGHUP (1) – reload configuration without restarting. SIGINT (2) – interrupt (Ctrl+C). SIGKILL (9) – force termination (cannot be caught). SIGTERM (15) – default termination request (can be caught).

List all signals with kill -l. Send a signal by name or number, e.g., kill -HUP 1234 or kill -9 1234.

6. Real‑Time Monitoring

6.1 top

top

provides a dynamic, full‑screen view of system activity. Useful options: -d SECS – set refresh delay. -b -n N – batch mode, output N iterations.

Interactive keys: M (sort by memory), P (sort by CPU), T (sort by time), c (show full command line), q (quit), k (kill a PID).

6.2 htop

htop

is a more user‑friendly, colorized alternative to top. It shows CPU load, memory usage, task list, and allows interactive sorting, filtering, and killing of processes. Function keys provide help (F1), setup (F2), search (F3), filter (F4), tree view (F5), sort (F6), nice‑adjust (F7/F8), kill (F9), and quit (F10).

htop interface showing CPU, memory, and process list
htop interface showing CPU, memory, and process list

7. Load Average

The three numbers shown by uptime or top are the system load averages for the past 1, 5, and 15 minutes. They represent the average number of runnable or uninterruptible processes. A load average lower than the number of logical CPUs indicates that the system is not saturated.

Example:

uptime
# 04:48:47 up 2 days,  3:02,  3 users,  load average: 0.00, 0.00, 0.00

8. Summary

Understanding Linux processes, their states, and the tools to view and control them is essential for system administration. Job control lets you manage foreground and background tasks, signals provide a way to communicate with processes, and monitoring utilities such as ps, top, and htop give real‑time insight into system performance.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

MonitoringLinuxsignalsjob-control
MaGe Linux Operations
Written by

MaGe Linux Operations

Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.