Skip to main content

Process Management

In Linux, every running program is a process consuming CPU cycles, memory, and I/O resources. Some processes run quietly in the background, while others demand immediate attention. Mastering process management allows you to observe, prioritize, and control these tasks, ensuring system stability and performance.


What is a Process?

A process is an instance of a running program. Each process has:

  • PID (Process ID): A unique identifier assigned by the kernel.
  • Parent Process: The process that created it (e.g., the shell).
  • Resources: CPU cycles, memory, file handles, and I/O.
  • Types: Foreground (interactive) or background (silent).
Linux is a multi-tasking OS, meaning many processes run simultaneously. The kernel schedules them using algorithms such as the Completely Fair Scheduler (CFS).

Core Process Commands

# Command Description
1 ps Lists active processes.
2 top Displays live resource usage of processes.
3 htop Interactive, colorful version of top.
4 jobs Lists background processes started in the shell.
5 fg / bg Moves processes between foreground and background.
6 kill Terminates a process by PID.
7 killall Terminates all processes with a given name.
8 nice / renice Adjusts process priority (CPU scheduling weight).

Process Lifecycle

StageDescription
CreatedSummoned by a parent process (e.g. shell).
ReadyWaiting for CPU time.
RunningActively executing instructions.
WaitingPaused, waiting for resources.
TerminatedProcess ends, resources released.
The kernel scheduler decides which process runs next. Foreground processes get direct attention, while background ones run quietly.

Signals: Messages to Processes

Processes can be controlled using signals:

# Signal Description
1 SIGTERM (15) Politely requests termination.
2 SIGKILL (9) Forcefully kills a process.
3 SIGSTOP Pauses a process.
4 SIGCONT Resumes a paused process.
kill -9 1729

# โ†’ Forcefully kills process with PID 1729

Practical Exercises

Try these commands to practice process management:

# Adjust process priority
nice -n 10 ./heavy_spell.sh
renice -n -5 <PID>

# Terminate a process
kill -9 <PID>

# Move process to foreground
fg %1

# Start a background process
sleep 100 &
jobs

# Monitor live processes
top

# List all processes
ps aux

Hackers Quest - Mini Project

Create a Potion Lab Simulation:

  1. Run three background processes (sleep, yes, ping).
  2. Use ps and top to observe them.
  3. Adjust one processโ€™s priority with nice.
  4. Kill one process gracefully, another forcefully.
  5. Document the lifecycle of each process in your spellbook.

Hackers Notebook

Processes are the living heartbeat of Linux. Some bubble gently, others roar with intensity. To master Linux, you must not only create programs but also control and manage the processes that run them. Command the cauldrons, and you command the kingdom.


Tips, Tricks, Roadmaps, Resources, Networking, Motivation, Guidance, and Cool Stuff โ™ฅ

Updated on Dec 31, 2025