DEV Community

LaTerral Williams
LaTerral Williams

Posted on

🖥️ Linux Process Management for Beginners: A Day in the Life of a Junior Sysadmin

You're the new Junior Sysadmin at a small but busy tech startup. It's your first week on the job, and you've just been asked to monitor, troubleshoot, and control running processes on the company's servers.

In this guide, you’ll learn how to monitor and manage Linux processes through hands-on examples. We’ll create dummy processes, explore real-time tools, and learn how to gently—or forcefully—handle misbehaving tasks.


📚 Table of Contents


🔧 Setting Up Your Practice Environment

Simulate real-world tasks by launching test processes:

Create a working directory:

mkdir ~/process-lab && cd ~/process-lab
Enter fullscreen mode Exit fullscreen mode

Create an infinite loop script:

echo -e '#!/bin/bash
while true; do echo "Working..."; sleep 5; done' > worker.sh
Enter fullscreen mode Exit fullscreen mode

🔍 Breakdown of What It Does:

echo -e
echo: Prints text to the terminal or into a file.

-e: Enables interpretation of backslash escapes (like \n for newline).

#!/bin/bash
This is a shebang. It tells the system to execute the script using the Bash shell.

while true; do echo "Working..."; sleep 5; done
This is an infinite loop:

while true; means “loop forever.”

echo "Working..." prints the message to the screen.

sleep 5 pauses for 5 seconds between each print to avoid spamming.

done marks the end of the loop block.

worker.sh
Redirects the whole output into a file called worker.sh.

If the file exists, it will be overwritten.


Make it executable:

chmod +x worker.sh
Enter fullscreen mode Exit fullscreen mode

Note: Review the kill cmd before proceeding, you'll thank yourself in a few moments.

Run it in the background:

./worker.sh &
Enter fullscreen mode Exit fullscreen mode

Note: Record the process ID (PID)

Image description

By now you are annoyed because Working... continues to print to screen. But we can discard the output with /dev/null or redirect it to a log by editing the script. Example here:

#!/bin/bash
while true; do
  echo "Working..." >> ~/process-lab/worker.log
  sleep 5
done
Enter fullscreen mode Exit fullscreen mode

I don't need the output for this example, so I will discard them.

#!/bin/bash
while true; do
  echo "Working..." >> /dev/null
  sleep 5
done
Enter fullscreen mode Exit fullscreen mode

Image description

Create a CPU-intensive process:

yes > /dev/null &
Enter fullscreen mode Exit fullscreen mode
  • yes prints "y" repeatedly; /dev/null discards the output. This simulates high CPU usage.

Image description


📊 Monitoring Processes in Real-Time

top

top
Enter fullscreen mode Exit fullscreen mode
  • What it does: Shows real-time info on CPU, memory, and processes.
  • Navigation tips: Use q to quit, P to sort by CPU, and M to sort by memory.

Image description

htop

htop
Enter fullscreen mode Exit fullscreen mode
  • What it does: A friendlier alternative to top with color and interactivity.
  • Useful features: Scrollable list, search with /, kill with F9.
  • Install it:
sudo dnf install htop
Enter fullscreen mode Exit fullscreen mode

Note: If htop is not available by default, try these additional steps:

Enable EPEL repository:

sudo dnf install epel-release
Enter fullscreen mode Exit fullscreen mode

Update your package index (optional):

sudo dnf update
Enter fullscreen mode Exit fullscreen mode

Image description

Image description


🔍 Viewing Detailed Process Info

ps aux

ps aux | grep worker.sh
Enter fullscreen mode Exit fullscreen mode
  • ps: Shows process snapshot.
  • a: Show processes from all users.
  • u: Display in user-oriented format.
  • x: Include background and non-terminal processes.
  • grep worker.sh: Filter to find our script.

Image description

pstree -p

pstree -p
Enter fullscreen mode Exit fullscreen mode
  • What it does: Displays processes as a tree with PIDs.
  • Great for spotting parent-child relationships.

🧼 Cleaning Up Processes

kill <PID>

kill 1234
Enter fullscreen mode Exit fullscreen mode
  • What it does: Sends signal (default: SIGTERM) to request graceful stop.

kill -9 <PID>

kill -9 1234
Enter fullscreen mode Exit fullscreen mode
  • -9 = SIGKILL: Forces termination without cleanup.
  • Use only if normal kill doesn't work.

pkill <name>

pkill worker.sh
Enter fullscreen mode Exit fullscreen mode
  • Ends all processes matching the name worker.sh.
  • Safer than hunting for PIDs manually.

Image description


🎯 Managing Background Jobs

Background a command with &

sleep 60 &
Enter fullscreen mode Exit fullscreen mode
  • Launches sleep as a background job.

Check jobs

jobs
Enter fullscreen mode Exit fullscreen mode
  • Shows background jobs for current session.

Image description

Bring job to foreground

fg %1
Enter fullscreen mode Exit fullscreen mode
  • %1: Refers to job number 1.

Image description

Send to background again

bg %1
Enter fullscreen mode Exit fullscreen mode

⚙️ Changing Process Priority

nice

nice -n 10 ./worker.sh &
Enter fullscreen mode Exit fullscreen mode
  • -n 10: Starts the process with a niceness of 10 (lower priority).
  • Range: -20 (high priority) to 19 (low priority).

Image description

renice

renice -n 5 -p 1234
Enter fullscreen mode Exit fullscreen mode
  • Changes priority of process 1234 to niceness 5.
  • Requires root to decrease niceness (i.e., increase priority).

Image description


🧪 Bonus Tools to Try

systemctl status <service>

systemctl status sshd
Enter fullscreen mode Exit fullscreen mode
  • Checks if the sshd service is running.
  • Useful for managing system-level daemons.

watch

watch -n 1 ps aux | grep worker
Enter fullscreen mode Exit fullscreen mode
  • Repeats a command every second.
  • Great for monitoring state changes.

strace

strace -p <PID>
Enter fullscreen mode Exit fullscreen mode
  • Traces system calls for a process.
  • Advanced troubleshooting tool.

🧠 Summary: Command Cheat Sheet

Command Description
top, htop Real-time CPU/memory monitoring
ps aux List all active processes
kill <PID> Gracefully stop a process
kill -9 <PID> Forcefully terminate a process
pkill <name> Kill process by name
jobs, fg, bg Manage shell background jobs
nice, renice Set or change process priority
pstree View process hierarchy
watch, strace Monitor and trace process behavior

✅ Wrap Up

Linux process management isn't just about knowing commands—it's about understanding how and when to use them. Set up a test environment, try each command, and you'll gain confidence in keeping your systems stable and responsive.

Happy sysadmin-ing!

Warp.dev image

The best coding agent. Backed by benchmarks.

Warp outperforms every other coding agent on the market, and gives you full control over which model you use. Get started now for free, or upgrade and unlock 2.5x AI credits on Warp's paid plans.

Download Warp

Top comments (1)

Some comments may only be visible to logged-in visitors. Sign in to view all comments.

Embedded BI Dashboards are 💩 Building them yourself is 💩

Embedded BI Dashboards are 💩 Building them yourself is 💩

Use our developer toolkit to build fast-loading, native-feeling dashboards for your customers (without the sh*t).

Get early access

👋 Kindness is contagious

Explore this practical breakdown on DEV’s open platform, where developers from every background come together to push boundaries. No matter your experience, your viewpoint enriches the conversation.

Dropping a simple “thank you” or question in the comments goes a long way in supporting authors—your feedback helps ideas evolve.

At DEV, shared discovery drives progress and builds lasting bonds. If this post resonated, a quick nod of appreciation can make all the difference.

Okay