Welcome to Day 19 of the 30 Days of Linux Challenge!
Today’s focus is all about process management — the backbone of performance monitoring and system control on any Linux-based system.
Processes are everywhere: system daemons, services, shell commands, and user applications. If you want to be a system administrator or DevOps engineer, this is a skill you must master.
📚 Table of Contents
- What Are Processes in Linux?
- View Running Processes
- Real-Time Monitoring with top
- Enhanced Process Monitoring with htop
- Controlling Processes (kill, pkill)
- Foreground vs Background Jobs
- Process Priorities with nice and renice
- Try It Yourself
- Common Process Tools Summary
- Why This Matters
What Are Processes in Linux?
A process is an instance of a running program.
Every process has:
- A unique PID (Process ID)
- A parent process (PPID)
- A state (e.g., sleeping, running)
- Resource usage (memory, CPU, etc.)
Everything from your terminal to the web server is a process — and they’re all managed by the Linux kernel.
View Running Processes
ps
– Process Snapshot
ps
ps aux
ps aux | grep sshd
Flag Meaning
a All users
u User format
x Show background processes
Real-Time Monitoring with top
top
Live view of:
- CPU & memory usage
- PID, user, command
Process states
Keys inside top:
- M → Sort by memory
- P → Sort by CPU
- k → Kill a process
- q → Quit
Enhanced Process Monitoring with htop
Flag Meaning
a All users
u User format
x Show background processes
Real-Time Monitoring with top
top
Live view of:
- CPU & memory usage
- PID, user, command
Process states
Keys inside top:
- M → Sort by memory
- P → Sort by CPU
- k → Kill a process
- q → Quit
Enhanced Process Monitoring with htop
sudo dnf install htop
htop
Features:
- Color-coded UI
- Easier navigation
- Interactive kill and renice
- Tree view of parent-child relationships
Controlling Processes (kill, pkill)
Kill by PID:
kill 1234
Force kill:
kill -9 1234
Kill by name:
pkill nginx
Foreground vs Background Jobs
Run in background:
./script.sh &
Show jobs:
jobs
Bring back to foreground:
fg %1
Suspend with:
Ctrl + Z
Process Priorities with nice and renice
Start process with lower priority:
nice -n 10 ./heavy_task.sh
Change priority of running process:
renice +5 -p 1234
Lower priority = friendlier to CPU.
Try It Yourself
Check all running processes
ps aux
Use top to monitor usage
top
Install and run htop
sudo dnf install htop
htop
Kill a test process
kill -9
Start a script in the background
./loop_script.sh &
jobs
fg %1
Common Process Tools Summary
Tool Purpose
ps View current running processes
top Live monitoring (CPU, memory)
htop Interactive and visual process tool
kill Stop a process by PID
pkill Kill a process by name
nice Start with specified priority
renice Change priority of running process
Why This Matters
- Without proper process management:
- Misbehaving programs can hog CPU or RAM
- Background scripts may go unnoticed
- You may lose control over your own server
Understanding how to view, analyze, and control processes is vital for:
- Performance optimization
- Stability
- Incident response