Linux Process Management Commands
A Linux process is a running instance of a program. Process management allows administrators and users to monitor running programs, identify resource usage, change process priority, and stop processes when necessary.
What is a Linux Process?
Whenever a program starts, Linux creates a process with its own process ID (PID), memory space, and execution state. The operating system manages these processes and allocates system resources to them.
Program → Process Created → PID Assigned → CPU/Memory Resources → Process Ends
What is a PID?
PID stands for Process ID. It is a unique number assigned by Linux to identify a running process.
ps
PID TTY TIME CMD
1234 pts/0 00:00:01 bash
5678 pts/0 00:00:00 nginx
How to View Running Processes
The ps command displays information about currently running processes.
ps
ps aux
ps -ef
Using the top Command
The top command provides a real-time view of running processes and system resource usage such as CPU and memory.
top
Using htop
htop is an interactive process viewer that provides an easier-to-read interface for monitoring processes. It may need to be installed separately depending on the Linux distribution.
htop
Finding a Process
The pgrep command can search for processes by name or other attributes.
pgrep nginx
pgrep -a python
Stopping a Process
The kill command sends a signal to a process. A normal termination signal should generally be preferred before using a forceful signal.
kill 1234
kill -TERM 1234
kill -KILL 1234
Common Process Signals
| Signal | Number | Purpose |
|---|---|---|
| SIGTERM | 15 | Request graceful termination |
| SIGKILL | 9 | Force immediate termination |
| SIGHUP | 1 | Hangup or reload behavior depending on application |
| SIGSTOP | 19 | Pause a process |
| SIGCONT | 18 | Resume a stopped process |
Changing Process Priority
Linux uses a nice value to influence CPU scheduling priority. The nice and renice commands can be used to start or adjust a process with a different priority.
nice -n 10 command
renice 5 -p 1234
Background and Foreground Processes
Shells allow commands to run in the foreground or background. Background execution is useful when a task should continue while the terminal remains available for other commands.
command &
jobs
fg %1
bg %1
Process Management Command Table
| Command | Purpose | Example |
|---|---|---|
| ps | Display processes | ps aux |
| top | Monitor processes in real time | top |
| pgrep | Find processes | pgrep nginx |
| kill | Send a signal | kill 1234 |
| nice | Start with a priority | nice -n 10 command |
| renice | Change process priority | renice 5 -p 1234 |
Example Troubleshooting Scenario
High CPU Usage → top → Identify PID → Inspect Process → Stop or Adjust Priority → Monitor Again
Common Process Management Mistakes
- Killing the wrong process
- Using SIGKILL when graceful termination would work
- Ignoring processes consuming excessive resources
- Changing priority without understanding the impact
- Running process-management commands with unnecessary privileges
Advanced Linux Process Concepts
- Parent and child processes
- Process states
- Zombie processes
- Orphan processes
- Signals
- CPU scheduling
- Control groups
Practice Exercises
- List all running processes
- Find a process by name
- Monitor CPU usage with top
- Terminate a test process gracefully
- Run a command in the background
- Change the priority of a test process
Conclusion
Linux process management provides the tools needed to monitor, control, and troubleshoot running applications. Commands such as ps, top, pgrep, kill, nice, and renice are essential for everyday Linux administration.