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.

TEXT
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.

BASH
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.

BASH
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.

BASH
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.

BASH
htop

Finding a Process

The pgrep command can search for processes by name or other attributes.

BASH
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.

BASH
kill 1234
kill -TERM 1234
kill -KILL 1234

Common Process Signals

SignalNumberPurpose
SIGTERM15Request graceful termination
SIGKILL9Force immediate termination
SIGHUP1Hangup or reload behavior depending on application
SIGSTOP19Pause a process
SIGCONT18Resume 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.

BASH
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.

BASH
command &
jobs
fg %1
bg %1

Process Management Command Table

CommandPurposeExample
psDisplay processesps aux
topMonitor processes in real timetop
pgrepFind processespgrep nginx
killSend a signalkill 1234
niceStart with a prioritynice -n 10 command
reniceChange process priorityrenice 5 -p 1234

Example Troubleshooting Scenario

TEXT
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.

Note: Note: Always verify the PID before sending signals, especially when working on production systems.