Welcome to Day 5 of the 30 Days of Linux Challenge!

Today’s topic is essential for anyone who wants to understand what’s happening under the hood of a Linux system: process management.

Processes are the running programs and services that keep your Linux system alive. Knowing how to view, manage, and control these processes is crucial for performance monitoring, debugging, and maintaining system stability.

📚 Table of Contents

What Is a Process in Linux?

A process is a running instance of a program or command. Whether you're editing a file in nano, running a Python script, or hosting a web app, each task becomes a process when it's executed.

Each process has:

  • A unique PID (Process ID)
  • An owner (user)
  • A state (running, sleeping, zombie, etc.)
  • A certain share of CPU and memory usage

Understanding processes allows you to monitor what’s active, troubleshoot performance issues, and terminate programs when needed.

Viewing Running Processes

Here are a few commands to inspect active processes:

ps – Process Snapshot

  1. ps aux | less
  2. a = all users
  3. u = display user
  4. x = include processes not attached to a terminal

This shows a detailed list of current processes. Use the less command to scroll through them.

top – Real-Time System Monitor

Shows processes in real time along with CPU, memory usage, load averages, and uptime.

Image description

htop – Enhanced Visual Monitor

If installed, htop offers a more interactive and colorful view of system activity. You can search, filter, and kill processes from within the UI.

Image description

To install:

  • sudo apt install htop # Debian/Ubuntu
  • sudo dnf install htop # Fedora/RHEL

Understanding Process States

Processes aren’t always actively running. They may be in different states:

State :: Meaning
R :: Running
S :: Sleeping (waiting for input/event)
T :: Stopped by signal
Z :: Zombie (terminated but not cleaned)
D :: Waiting for I/O

Zombie processes should be cleared; sleeping/stopped processes may indicate an issue if persistent.

Controlling and Managing Processes

kill – Terminate a Process by PID
kill 1234

Gracefully asks the process to terminate.

kill -9 – Force Kill (Use with Caution)
kill -9 1234

Forcefully kills a process (use only if kill doesn’t work).

killall – Kill by Name
killall firefox
Kills all processes with the name "firefox".

nice and renice – Set Process Priority

By default, all processes are treated equally, but you can lower or raise their priority using nice values.

nice -n 10 command # Starts a command with lower priority
renice -n 5 -p 1234 # Changes priority of a running process
Lower nice = higher priority
Range: -20 (highest) to +19 (lowest)

Working with Background Jobs

When you run a command, it takes over your terminal. But you can move it to the background:

& – Run command in background

sleep 30 &
jobs – List background jobs

fg – Bring background job to foreground

bg – Resume a suspended job in background

This is useful when managing multiple tasks in one terminal session.

Try It Yourself

Here’s a quick exercise to get hands-on:

  1. ps aux | grep bash # Find your shell process
  2. top # Watch live CPU/memory usage
  3. sleep 60 & # Run a background job
  4. jobs # Check running jobs
  5. kill %1 # Kill background job with job number

Explore man ps, man top, and man kill to go deeper into each command.

Why This Matters

If you’re a system administrator, DevOps engineer, or cloud practitioner, process control is non-negotiable.

You’ll use these skills to:

  1. Detect and kill rogue processes
  2. Monitor system resource usage
  3. Prioritize critical services
  4. Automate monitoring and alerts

Whether you're debugging a server crash, diagnosing a slow app, or simply optimizing performance — this knowledge keeps your systems efficient and stable.