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
Or sometimes:
Start → Run → Crash 😅
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
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
Show all processes:
ps aux
Alternative format:
ps -ef
Understanding ps Output
Example:
USER PID %CPU %MEM COMMAND
ana 1234 0.5 1.2 python app.py
| 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
Example:
ps aux | grep docker
This searches for running Docker processes.
Monitoring Processes in Real Time
top
The top command provides a live view of running processes.
top
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
Run:
htop
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
Your terminal remains occupied until the command finishes.
Run a Process in the Background
Add & at the end:
sleep 500 &
Output:
[1] 12345
Where:
-
[1]= Job number -
12345= PID
Your terminal becomes available immediately.
Listing Background Jobs
View jobs running in the current terminal:
jobs
Example:
[1]+ Running sleep 500 &
Moving Jobs Between Background and Foreground
Bring a job back to the foreground:
fg %1
Send a suspended job to the background:
bg %1
Pause a Running Process
Press:
Ctrl + Z
This pauses the process without terminating it.
Then resume it:
bg
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
This sends:
SIGTERM (15)
The application gets a chance to clean up before stopping.
Force Kill
kill -9 12345
This sends:
SIGKILL (9)
The process stops immediately.
No cleanup occurs.
Best Practice
Always try:
kill PID
before:
kill -9 PID
Force-killing applications can sometimes cause data corruption.
Killing Processes by Name
Instead of finding the PID manually:
pkill nginx
Or:
killall nginx
Very useful during troubleshooting.
Checking Disk Space
One of the most common production issues is a full disk.
Check disk usage:
df -h
Example output:
Filesystem Size Used Avail Use%
/dev/sda1 50G 32G 16G 67%
The -h flag means:
Human Readable
Checking Memory Usage
Use:
free -h
Example:
Mem: 7.8G 2.1G 3.2G
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
Not:
Free
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
Starting a Service
sudo systemctl start nginx
Stopping a Service
sudo systemctl stop nginx
Restarting a Service
sudo systemctl restart nginx
Checking Service Status
sudo systemctl status nginx
One of the most frequently used commands in Linux administration.
Enable Service at Boot
Automatically start after reboot:
sudo systemctl enable nginx
Disable automatic startup:
sudo systemctl disable nginx
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
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
Then:
sudo systemctl restart myapp
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)