GICT knowledge base
Understanding Process Management Commands in Linux for Beginners
Published
When you first step into the world of Linux, the system may seem a bit mysterious. You see windows and icons like any modern operating system, but under the hood, Linux is all about processes—small, running programs that together make up everything you see and do. Whether you’re opening a text editor, connecting to Wi-Fi, or running a web server, each of these actions starts one or more processes.
Managing these processes is a fundamental skill for anyone using Linux. It’s the key to troubleshooting, tuning performance, and even keeping your system secure. Once you understand how to view, control, and manipulate running processes, you’re no longer just a user—you become the pilot of your own system.
This guide walks you through everything a beginner needs to know about process management in Linux. You’ll learn not only about the essential commands but also why they matter, what the output means, and how you can apply this knowledge to real-world situations.
Prerequisites
Before you start, make sure you have:
- Access to a Linux machine (physical, virtual, or remote).
- Terminal or SSH access to type commands.
- Basic familiarity with navigating the command line (for example, using cd, ls, and pwd).
No advanced permissions are required for most commands, but some actions (like stopping system services) will require superuser (root) access.
What Is a Process?
In the simplest terms, a process is an instance of a running program. Every time you run a command or open an application, Linux creates a process for it. Each process is given a unique Process ID (PID), which helps the system manage and keep track of it.
Processes can be:
- Foreground processes: These run in your terminal and interact directly with you.
- Background processes: These run silently in the background, often started by the system or by you with special syntax.
Processes can also be:
- Parent processes: Start other processes (children).
- Child processes: Started (spawned) by a parent.
Understanding how processes relate to each other and to your own commands is the first step toward effective management.
Viewing Running Processes
To manage processes, you first need to see what’s running on your system. Linux offers several commands for this purpose.
ps — Process Status
The ps command gives you a snapshot of the currently running processes.
ps
By default, this shows only processes running in your current terminal session. For a broader view, use:
ps aux
- a shows processes for all users.
- u displays the user/owner column.
- x lists processes not attached to a terminal (like background services).
A typical ps aux output looks like this:
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
yourname 2045 0.0 0.1 35664 4628 pts/0 Ss 10:32 0:00 bash
yourname 2107 0.1 0.2 59776 8652 pts/0 R+ 10:33 0:00 ps aux
- USER: Who owns the process.
- PID: The process ID.
- %CPU and %MEM: CPU and memory usage.
- VSZ and RSS: Virtual and resident memory sizes.
- TTY: Terminal associated with the process.
- STAT: Process state (see below).
- START: Start time.
- TIME: CPU time used.
- COMMAND: The command that started the process.
Understanding Process States
The STAT column shows one or more letters:
- R: Running
- S: Sleeping
- D: Uninterruptible sleep (usually IO)
- Z: Zombie (the process has finished but still has an entry in the process table)
- T: Stopped (by a job control signal)
Understanding these states helps you spot issues like stuck (zombie) or sleeping processes.
top — Real-Time Process Viewer
The top command is like a live dashboard for your system’s processes. It updates automatically, showing which processes are consuming the most CPU and memory.
top
At the top of the display, you’ll see system stats: uptime, load average, total tasks, CPU usage, and memory usage. Below, a list of processes sorted by resource use.
Keys you’ll use in top:
- q — Quit.
- k — Kill a process (prompts for PID).
- P — Sort by CPU usage.
- M — Sort by memory usage.
- h — Help.
htop — An Enhanced Alternative
htop is a more user-friendly alternative to top, with color displays, mouse support, and easier controls. It’s not always installed by default, but you can usually add it with your package manager:
sudo apt install htop # Debian/Ubuntu
sudo dnf install htop # Fedora/RHEL
Run it:
htop
You’ll see a list of processes with interactive controls. Use the arrow keys to select a process, and function keys to kill or renice processes.
pgrep and pidof — Find PIDs by Name
If you want to quickly find the PID of a running process:
pgrep firefox
Or:
pidof bash
Both commands return process IDs for the named program.
Starting and Stopping Processes
Running Programs in the Foreground and Background
When you type a command, it starts in the foreground. You can’t use the terminal again until the process finishes. To run a process in the background, add & at the end:
firefox &
The terminal prints the process’s PID and returns you to the prompt.
Suspending and Resuming Processes
You can suspend a foreground process by pressing Ctrl+Z. The process stops and can be resumed later.
To bring it back to the foreground, type:
fg
To send it to the background, type:
bg
This is helpful when you need to pause a long-running process without quitting.
Listing Background and Suspended Jobs
Use the jobs command to see what’s suspended or running in the background:
jobs
Output example:
[1]+ Running script.sh &
[2]- Stopped nano notes.txt
Controlling Processes: Stopping, Killing, and Prioritizing
Stopping Processes Gracefully: kill and killall
To stop a process, you need its PID (find this with ps, top, or pgrep). The most common command is:
kill 1234
By default, kill sends signal 15 (TERM), which politely asks the process to stop. If that fails, you can force it with signal 9 (KILL):
kill -9 1234
Use signal 9 only as a last resort, since it can cause data loss.
Killing by Name
If you want to stop all instances of a program:
killall firefox
Again, use the -9 flag if necessary:
killall -9 firefox
Pausing and Resuming Processes: kill -STOP and kill -CONT
To pause a process without quitting it:
kill -STOP 5678
To resume it:
kill -CONT 5678
This can be handy for temporarily suspending resource-heavy applications.
Managing Process Priority: nice and renice
Not all processes are equally important. Sometimes you want to run a big backup or a system update without slowing down other tasks. Linux lets you set process priority using “nice” values.
Starting a Process with a Lower Priority
nice -n 10 long_task.sh
The default nice value is 0. Higher numbers mean lower priority (range: -20 to 19). Only the root user can set negative (higher-priority) values.
Changing the Priority of Running Processes
Use renice to adjust an already-running process:
renice 15 1234
You’ll need the PID and, for higher priorities, root access.
Monitoring and Analyzing Processes
Viewing Child and Parent Relationships
Every process (except the very first, called init or systemd) has a parent. To see these relationships, try:
pstree
This displays a tree of processes, showing which ones started others.
Checking Memory and CPU Usage
The top and htop commands show you which processes are using the most resources. For a quick snapshot:
ps aux --sort=-%mem | head
Shows the top memory consumers.
ps aux --sort=-%cpu | head
Shows the top CPU consumers.
Watching a Single Process
If you want to monitor one process over time:
top -p 1234
This filters the top display to show only the process with PID 1234.
Practical Scenarios
Scenario 1: Stopping a Frozen Application
Suppose Firefox is unresponsive. You first find its PID:
pgrep firefox
Let’s say the output is 2345.
Try stopping it gracefully:
kill 2345
If it doesn’t quit:
kill -9 2345
Scenario 2: Running a Backup in the Background
You want to run a backup script but keep using your terminal:
./backup.sh &
If you forget to add &, suspend with Ctrl+Z, then run:
bg
Scenario 3: Lowering Priority for a Heavy Process
You’re compressing a large folder but want your web browser to stay responsive:
nice -n 15 tar -czvf backup.tar.gz ~/Documents
Or, if you forgot and the process is already running (PID 5678):
renice 15 5678
Scenario 4: Checking Which Process Uses a Port
Suppose a service won’t start, and you suspect another process is using its port:
sudo lsof -i :80
This shows which process is using port 80 (commonly used by web servers).
Avoiding Common Pitfalls
- Don’t use kill -9 unless necessary. It doesn’t let processes clean up, which can cause problems.
- Double-check PIDs to avoid killing the wrong process.
- Be careful with system processes (owned by root or systemd); stopping these may destabilize your system.
- Always try to use graceful termination before forcing a process to quit.
- Use nice and renice thoughtfully—giving everything a high priority defeats the purpose.
Useful Shortcuts and Additional Tools
- Tab completion: Saves time typing process names.
- Command history (!!, !ps): Speeds up repetitive management.
- nohup and disown: Run a process that keeps going even if you log out.
- xkill: Click to force-close a graphical application window.
Scripting and Automation
You can combine process management commands in scripts. For example, a daily script to check for zombie processes:
ps aux | awk '$8 ~ /Z/ { print $2 " " $11 }'
This prints the PIDs and names of all zombie processes.
Conclusion
Understanding and managing processes is an essential part of using Linux. While the idea of “processes” might seem technical at first, the commands you’ve learned—ps, top, htop, kill, nice, and others—are your essential toolkit for keeping your system healthy and responsive.
As you get more comfortable, you’ll start to recognize which processes are normal, which are resource hogs, and which might need your attention. When something freezes, you’ll know how to check what’s running and take appropriate action, whether that’s suspending, resuming, or stopping a process.
The real power of Linux isn’t just in its flexibility, but in the control it gives you as a user. With a solid grasp of process management, you become a true operator of your system—capable, confident, and ready to solve problems as they arise.
Remember: every expert started as a beginner. Keep exploring, practicing, and experimenting, and soon you’ll be as comfortable with process management as you are with any other everyday task in Linux.
Related guides
How to Restrict an SSH Key to One Command
Restrict an SSH key to one command with authorized_keys options. Protect the command and check that unwanted shell and forwarding access are denied.
Linux and CommandsSelf-Hosted Video Processing With FFmpeg: A Practical Guide
Learn how to self-host video processing on a VPS using FFmpeg, with practical commands for conversion, compression, thumbnails, and automated workflows.
Linux and CommandsHow to use nohup: Commands in Linux That Survive Terminal Closes
Keep commands running after you close the terminal. nohup examples with wget, Python, rsync, and Docker on any VPS.
Linux and CommandsHow to Fix “Too Many Open Files” Error on Linux Servers
Learn how to fix the "Too Many Open Files" error on Linux servers by understanding file descriptors, adjusting limits, and diagnosing leaks effectively.
