![]() |
Managing
processes in Linux is one of the core skills that every user should learn,
whether you are new to the system or already familiar with the basic commands. Process management allows you
to understand how your system runs the programs, handles multitasking and uses
the system resources efficiently.
Process
management is used in monitoring, controlling, and optimizing the active
programs and background services that are running on your Linux system. With
tools such as ps, top, htop, kill, and nice, you can easily monitor the system
performance, terminate the unresponsive applications, adjust the process
priorities, and troubleshoot the system performance issues in real time.
This
guide will help system administrators, DevOps engineers and end users to
understand the process management in Linux, process types and how to manage
them efficiently.
Any
running program or an instance of a running program is referred to as a process
in Linux. When you launch an application, run a script or execute any command
then the Linux kernel creates a new process to manage that execution.
Every
program that you run or any command that you execute in the terminal is
considered as a process in Linux. These processes can either run in the
background or foreground, depending on how you start or control them.
Understanding of this concept is very important for multitasking and efficient
system management.
A foreground process runs directly, interacts with the user and occupies the terminal until the task is completed. The terminal cannot be used for any other task or command until the running foreground process is finished or stopped.
A
background process runs independently without occupying the terminal and allows
you to continue using the same terminal for other tasks. You can send the
process to the background by adding the ampersand (&) at end of the
command. ![]()
As you can see, vim command is running in the background. You will just get the process ID (PID) and your terminal will be immediately available for other commands.
Command Description
Jobs Lists
all running background jobs
Fg
%job_id Brings
background jobs to foreground
Bg
%job_id resumes
a stopped job in the background
Ctrl
+ Z suspends
a foreground process
Kill %job_id terminates a background job
Commands with Examples
1. Jobs
Every
process originates from another process, just like a family tree. The process
that creates another process is called a parent process and the new process initiated
by the parent process is called a child process. Understanding this fundamental
concept is important for system administrators and developers as it helps to
grasp how your system handles multitasking and controls the processes.
A
parent process is a process that can create one or more new processes. It
initiates another process using a system call like fork () or a command
executed from the shell.
When
you open a terminal such as bash, it runs as a process and you execute any
command in that terminal, then bash becomes a parent process and the command
becomes the child process.
A
child process is a process that is created by a parent process using the fork
() system call or by executing any command. It inherits some characteristics
from the parent process, such as environment variables, file descriptors and
user ID but it has a unique process id (PID).
On
exit or termination of the child process SIGCHLD signal is sent to the parent
process to inform about the termination or interruption of the child process.
|
Term |
Description |
Example |
|
Parent
Process |
creates
another process |
bash,
starting ls |
|
Child
Process |
created
by parent process |
ls
command |
|
Orphan
Process |
The
parent terminated before the child |
adopted
by init |
|
Zombie
Process |
A
completed child not reaped by the parent |
ps
aux |
Why It Matters
Understanding parent and child processes is vital for
· Debugging process trees
· Managing system performance
· Prevent orphan or zombie processes
Linux Process States
Every process goes through different states in its lifecycle in Linux. Understanding these states helps system administrators and developers diagnose system performance, manage task effectively and troubleshoot issues.
Mostly,
the process spends time here. Seen as S or D in the top.
A
process enters in stopped state when it receives a SIGSTOP or SIGTSTP signal.
Its execution is suspended and it will only resume on receiving a SIGCONT
signal or be terminated by SIGKILL. It can be stopped using Ctrl + Z in the
terminal and seen as T in top or ps.
A
process goes in zombie states when a child process terminates but its parent
process has not called wait or waitpid () to collect its exit status. The
zombie process is dead but its entry in the process table remains until reaped
by the parent. Seen as “Z” in top or ps and consumes no CPU or memory.
|
State |
Symbol |
Description |
Command |
|
Running |
R |
Actively
using CPU or waiting to run |
ps
-eo pid, state,cmd |
|
Sleeping |
S/D |
waiting
for an event or I/O |
ps
-eo pid, state, cmd |
|
Sopped |
T |
suspended
or paused |
ps
-eo pid, state, cmd |
|
Zombie |
Z |
process
finished, but not reaped |
ps
aux |
The
kernel is the core part of the operating system, responsible for managing all
processes, hardware resources, and system operations. It is a bridge between
hardware and software, ensuring that every process gets the CPU, memory, and I/O
resources they need to run effectively.
When
a new process is created, the kernel assigns it a unique process ID (PID), a
numerical identifier that is used to track and manage the process throughout
its lifecycle. Every process, whether it’s a system daemon, a user application
or a background service, has its own PID.
Viewing Active Processes with ps in Linux
One
of the most commonly used commands for monitoring running processes is the ps
(Process Status) command. It provides detailed information about active
processes, including their PID (Process ID), PPID (Parent Process ID), CPU
usage, memory usage and execution state. Understanding how to use the ps
command is a fundamental skill for any Linux administrator or beginner learning
process management.
The
ps command reads data directly from the kernel and displays it in a
human-readable format, making it useful for quick system checks and diagnoses.
This filters the process list to show only entries matching the keyword “gitlab”. It is a quick way to check if a service or process is running.
#ps -ef | grep gitlab
The
top command is the most commonly used and powerful utility in Linux for
real-time process monitoring. It provides a continuous, updated view of system
performance, including CPU usage, memory consumption, running tasks, and
process ID (PID).
When
you run top it retrieves data directly from /proc file system, which contains
runtime system information such as process details, CPU statistics and memory
usage. The display refreshes after every few seconds and gives a current
overview of system activity to the administrators.
Sometimes
a process may hang, consume too many resources or behave unexpectedly. In such
situations, you may need to stop or terminate the process manually. Linux
offers several commands for this purpose, such as kill, pkill, and killall,
each offering a different level of control.
The
kill command sends a signal to the process ID (PID) to stop or terminate it.
You can view the PID of a running process using ps or top command.
The
pkill command allows you to terminate processes by name instead of PID. It is
especially useful when you have multiple instances of the same program. 
The
killall command terminates all processes that share the same name, similar to
pkill but with broader reach across the sessions. 
Process
priority determines how much CPU time a process receives as compared to other
processes. Adjusting priority helps manage system performance by allocating more CPU time to critical tasks and prioritizing less important ones. This is
done using nice and renice commands.
One
of the most vital skills that one can have, regardless of whether he is a
beginner and venturing into the world of Linux or an expert administrator
dealing with production servers, is process management in Linux.
This
guide has made you visualize an active process, performance of a diagnostic
system, prioritization with nice and renice, and an unresponsive process, which
is ended through tools such as ps, top, and htop. You have also heard of the
functionality of processes behind the scenes in the Linux kernel, how processes
are allocated PIDs (Process IDs) and how the system gets to be steady and
stable with good scheduling.
Process
management enables you to have full control over your system. By following the
orders and the good practices that are presented in this guide, you will be
able to learn more about the way in which Linux manages to cope with
multitasking and resource distribution.
No
matter how you use Linux, be it with background service management, performance
troubleshooting, or just to view the inner workings of Linux, having command
over processes provides you with the skills and ability to deal with any
condition of a system.
Continue to visit SeekLinux to get more tutorials about Linux, command explanations, beginner to expert tutorials that would help you develop your abilities in the real-world Linux environments.





















![Terminal command ps -ef | grep [pattern] used to filter the list of all running processes for a specific keyword or process name, showing matching process details including PID, PPID, and command.](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjcNNoJEjHZyVktGjSWSJSoTXcvM2IsIMwpUvww6S8npLAM14IvfPGXqVeNLPr829mQOA-MWla5Pk6zji3akfgacAQtTk_5rFMDS-QuZgVXzzM6wpwvi44P8W-9tLYF9dZ4KgbNMqFzpWejtd1VPy_praUZCQg-dnii1j31Ngczjx_GtjKPo9OQ559QrOLr/w640-h206-rw/ps%20gitlab.png)



Post a Comment