Skip to content

The Art of Process Management – Controlling the Chaos

In the mystical world of Linux, everything you run is a process—from opening a terminal to running a server. But some processes are obedient, while others… go rogue. 😈

Today, we learn to create, monitor, and terminate processes with precision.

Understanding Processes

Want to see all running processes? Use:

bash
ps aux

You’ll get something like:

bash
ninja    1234  1.2  0.3  45678  5678 ?   S   10:00   0:01 python3 script.py

What does this mean?

🏷 Column🧐 Meaning
ninjaUser who owns the process
1234Process ID (PID)
1.2CPU usage (%)
0.3Memory usage (%)
SProcess state (S = Sleeping, R = Running, Z = Zombie)
python3The command running

If you need live monitoring, use:

bash
top

or its fancy cousin:

bash
htop  # Install it with 'sudo apt install htop'

Starting Processes – The Summoning Ritual

Run a program normally:

bash
firefox

But it locks your terminal! 😱 To run it in the background, use:

bash
firefox &

The & tells Linux: "Run this, but don’t hold my terminal hostage!" 🎭

Want to see background jobs? Use:

bash
jobs

To bring a background job back to the foreground:

bash
fg %1  # If it's job number 1

Finding a Process

To find a specific process, use:

bash
ps aux | grep firefox

or

bash
pgrep -l firefox

This will show the process ID (PID), which is important for… 👇

Killing a Process – When Things Go Wrong

Sometimes, programs freeze or consume too many resources. You need to terminate them with style:

bash
kill PID

Example:

bash
kill 1234  # Politely asks process 1234 to exit

If the process ignores you? Bring out the big guns:

bash
kill -9 1234  # Immediate termination. No mercy. 🚀

Or just use:

bash
pkill firefox  # Kill all processes with "firefox" in their name

For extreme measures, wipe out everything from a user:

bash
killall -u ninja

Careful! This logs the user out instantly. 😈

Controlling Running Processes

⏸ Pausing a Process

Ever wanted to pause a process without killing it? Use:

bash
Ctrl + Z  # Freezes the running process

To resume it in the foreground:

bash
fg

To resume it in the background:

bash
bg

Giving a Process Superpowers (Nice & Renice)

To change process priority:

bash
nice -n 10 long_running_script.sh  # Lower priority
nice -n -5 important_task.sh  # Higher priority

To change the priority of an existing process:

bash
renice -n 5 -p 1234  # Adjust priority of process 1234

Built by noobs, for noobs, with love 💻❤️