DEV Community

Cover image for ⚙️ Linux Process Management Every DevOps Engineer Should Know
Md Mohiuddin
Md Mohiuddin

Posted on

⚙️ Linux Process Management Every DevOps Engineer Should Know

When an application stops responding, a server becomes slow, or a deployment suddenly fails, one of the first places a DevOps engineer looks is the Linux process list.

Every web server, database, monitoring agent, Docker container, and CI/CD tool ultimately runs as a process inside the operating system.

Understanding how processes work is a fundamental Linux skill that will help you troubleshoot servers, monitor resource usage, and manage applications effectively.

In this article, I'll cover:

✅ What a process is
✅ Viewing running processes
✅ Monitoring CPU and memory usage
✅ Running jobs in the background
✅ Killing processes safely
✅ Checking disk and memory usage
✅ Managing services with systemctl

Let's dive in.


Why Process Management Matters in DevOps

Every application you deploy goes through a lifecycle:

Start → Run → Stop
Enter fullscreen mode Exit fullscreen mode

Or sometimes:

Start → Run → Crash 😅
Enter fullscreen mode Exit fullscreen mode

As a DevOps engineer, you'll frequently need to answer questions like:

  • Is my application actually running?
  • Why is the server slow?
  • Which process is consuming all the memory?
  • How can I stop a misbehaving process?
  • How do I ensure my application restarts after a reboot?

Linux process management provides the answers.


What Is a Process?

A process is simply a running instance of a program.

For example:

python app.py
Enter fullscreen mode Exit fullscreen mode

When you run this command, Linux creates a new process.

Every process has:

  • A Process ID (PID)
  • A Parent Process ID (PPID)
  • CPU usage
  • Memory allocation
  • A current state

Each running application on your system is represented by one or more processes.


Viewing Running Processes

Using ps

The ps command provides a snapshot of currently running processes.

Show processes running in your current terminal:

ps
Enter fullscreen mode Exit fullscreen mode

Show all processes:

ps aux
Enter fullscreen mode Exit fullscreen mode

Alternative format:

ps -ef
Enter fullscreen mode Exit fullscreen mode

Understanding ps Output

Example:

USER   PID  %CPU %MEM COMMAND
ana   1234   0.5  1.2 python app.py
Enter fullscreen mode Exit fullscreen mode
Column Meaning
USER Process owner
PID Process ID
%CPU CPU usage
%MEM Memory usage
COMMAND Executed command

Finding a Specific Process

One of the most common DevOps commands:

ps aux | grep nginx
Enter fullscreen mode Exit fullscreen mode

Example:

ps aux | grep docker
Enter fullscreen mode Exit fullscreen mode

This searches for running Docker processes.


Monitoring Processes in Real Time

top

The top command provides a live view of running processes.

top
Enter fullscreen mode Exit fullscreen mode

Useful shortcuts inside top:

Key Action
P Sort by CPU usage
M Sort by memory usage
k Kill a process
q Quit

htop

A more user-friendly version of top.

Install:

sudo apt install htop
Enter fullscreen mode Exit fullscreen mode

Run:

htop
Enter fullscreen mode Exit fullscreen mode

Benefits:

  • Color-coded interface
  • Easier navigation
  • Better process management

Many Linux administrators prefer htop for daily use.


Running Processes in the Background

Normally, commands run in the foreground.

Example:

sleep 500
Enter fullscreen mode Exit fullscreen mode

Your terminal remains occupied until the command finishes.


Run a Process in the Background

Add & at the end:

sleep 500 &
Enter fullscreen mode Exit fullscreen mode

Output:

[1] 12345
Enter fullscreen mode Exit fullscreen mode

Where:

  • [1] = Job number
  • 12345 = PID

Your terminal becomes available immediately.


Listing Background Jobs

View jobs running in the current terminal:

jobs
Enter fullscreen mode Exit fullscreen mode

Example:

[1]+ Running sleep 500 &
Enter fullscreen mode Exit fullscreen mode

Moving Jobs Between Background and Foreground

Bring a job back to the foreground:

fg %1
Enter fullscreen mode Exit fullscreen mode

Send a suspended job to the background:

bg %1
Enter fullscreen mode Exit fullscreen mode

Pause a Running Process

Press:

Ctrl + Z
Enter fullscreen mode Exit fullscreen mode

This pauses the process without terminating it.

Then resume it:

bg
Enter fullscreen mode Exit fullscreen mode

This is useful for long-running commands.


Stopping Processes

Linux uses signals to communicate with processes.

The kill command sends those signals.


Graceful Shutdown

kill 12345
Enter fullscreen mode Exit fullscreen mode

This sends:

SIGTERM (15)
Enter fullscreen mode Exit fullscreen mode

The application gets a chance to clean up before stopping.


Force Kill

kill -9 12345
Enter fullscreen mode Exit fullscreen mode

This sends:

SIGKILL (9)
Enter fullscreen mode Exit fullscreen mode

The process stops immediately.

No cleanup occurs.


Best Practice

Always try:

kill PID
Enter fullscreen mode Exit fullscreen mode

before:

kill -9 PID
Enter fullscreen mode Exit fullscreen mode

Force-killing applications can sometimes cause data corruption.


Killing Processes by Name

Instead of finding the PID manually:

pkill nginx
Enter fullscreen mode Exit fullscreen mode

Or:

killall nginx
Enter fullscreen mode Exit fullscreen mode

Very useful during troubleshooting.


Checking Disk Space

One of the most common production issues is a full disk.

Check disk usage:

df -h
Enter fullscreen mode Exit fullscreen mode

Example output:

Filesystem Size Used Avail Use%
/dev/sda1 50G 32G 16G 67%
Enter fullscreen mode Exit fullscreen mode

The -h flag means:

Human Readable
Enter fullscreen mode Exit fullscreen mode

Checking Memory Usage

Use:

free -h
Enter fullscreen mode Exit fullscreen mode

Example:

Mem: 7.8G 2.1G 3.2G
Enter fullscreen mode Exit fullscreen mode

Important columns:

Column Meaning
Used Memory currently used
Free Completely unused memory
Available Memory available to applications

Common Beginner Mistake

Many people panic when they see low "Free" memory.

Linux intentionally uses unused RAM for caching.

The important value is:

Available
Enter fullscreen mode Exit fullscreen mode

Not:

Free
Enter fullscreen mode Exit fullscreen mode

Managing Services with systemctl

Running commands with & works for temporary tasks.

Production services require something more reliable.

Examples:

  • Nginx
  • Docker
  • Jenkins
  • PostgreSQL
  • Redis

These services are managed using:

systemctl
Enter fullscreen mode Exit fullscreen mode

Starting a Service

sudo systemctl start nginx
Enter fullscreen mode Exit fullscreen mode

Stopping a Service

sudo systemctl stop nginx
Enter fullscreen mode Exit fullscreen mode

Restarting a Service

sudo systemctl restart nginx
Enter fullscreen mode Exit fullscreen mode

Checking Service Status

sudo systemctl status nginx
Enter fullscreen mode Exit fullscreen mode

One of the most frequently used commands in Linux administration.


Enable Service at Boot

Automatically start after reboot:

sudo systemctl enable nginx
Enter fullscreen mode Exit fullscreen mode

Disable automatic startup:

sudo systemctl disable nginx
Enter fullscreen mode Exit fullscreen mode

Understanding a Service File

Example:

[Unit]
Description=My Application
After=network.target

[Service]
ExecStart=/usr/bin/python3 /home/user/app.py
Restart=always
User=user

[Install]
WantedBy=multi-user.target
Enter fullscreen mode Exit fullscreen mode

Important fields:

Field Purpose
ExecStart Command to run
Restart=always Restart automatically if it crashes
User Run as a specific user
WantedBy Start during system boot

Reload systemd After Changes

After editing a service file:

sudo systemctl daemon-reload
Enter fullscreen mode Exit fullscreen mode

Then:

sudo systemctl restart myapp
Enter fullscreen mode Exit fullscreen mode

Quick Command Reference

Command Purpose
ps View running processes
ps aux View all processes
top Live process monitoring
htop Enhanced process monitoring
jobs List background jobs
fg Move job to foreground
bg Move job to background
kill Stop a process gracefully
kill -9 Force kill a process
pkill Kill process by name
killall Kill all matching processes
df -h Check disk usage
free -h Check memory usage
systemctl start Start a service
systemctl stop Stop a service
systemctl restart Restart a service
systemctl status View service status
systemctl enable Auto-start service on boot

Final Thoughts

Process management is one of the most important Linux skills for DevOps engineers.

Whether you're troubleshooting a slow server, debugging an application, monitoring resource usage, or managing production services, these commands become part of your daily toolkit.

The more comfortable you become with processes and services, the easier it will be to work with Docker containers, Kubernetes workloads, CI/CD pipelines, and cloud infrastructure.

I'm currently documenting my DevOps learning journey and sharing beginner-friendly notes as I learn.

If you have favorite Linux troubleshooting commands, feel free to share them in the comments.

Happy Learning! 🐧🚀

Top comments (0)