Modern technology gives us many things.

Linux Process Management: The Ultimate Guide



In Linux and Unix-based operating systems, a running command instance is known as a process. You can identify each process by a unique process ID. Linux provides command-line tools to list, manage, and monitor these processes efficiently.

You can use these tools to prioritize each process or put them in the background or foreground to manage system resources efficiently.

This guide to process management in Linux includes tools such as ps, kill, renice, and other commands that assist system administrators in managing and listing processes.

Listing Processes With the ps Command

The oldest and most commonly used command-line utility to list currently running processes on Linux is ps. Even though the top command is another interactive and screen-oriented way to manage and list system processes, ps also displays additional information like the resources each process is consuming.

Due to a multiuser environment, each process in Linux is associated with a separate user and group account. Hence, account information with process details helps you access the system resources a process can use.

For instance, processes running with superuser privileges can access more system resources than a regular user, and this is where ps helps system administrators.

The following output is an example of listing processes with usernames, the elapsed time, and associated memory and CPU consumption:

ps Command User Processes

You can also note the STAT column that shows the state of the running process. R represents the process is running currently, and S is a sleeping process with a plus sign indicating foreground operations.


You can list all the processes of the current user, as follows:

ps ux | less

To list processes for all users:

ps aux | less

Managing Processes With System Monitor

System Monitor provides a graphical way of displaying and managing processes. To launch System Monitor, go to Applications > System Monitor. Switch to the Processes tab to view all the running processes.

System Monitor

By default, it displays processes in alphabetical order for the current user. You can re-sort the process listing by clicking on any column heading. Besides, you can click on the %CPU and Memory headings to view processes consuming more processing power and memory.

System Monitor Process Management

System Monitor allows you to manage processes in various ways, which means you can stop, kill, continue, end, and change process priority by simply right-clicking a process name.

It’s the best go-to tool for novice Linux users who do not know how to work with command-line utilities.

Related: How to Display top Processes Result and Sort by Memory

Working With Background/Foreground Processes

There comes a time when you have to access a Linux system over a network using only a command line. This limits the effective management of multiple active programs. But a shell allows you to manage programs by toggling them into background and foreground.

How to Start a Background Process

To start a program while you continue to work in the shell, run the command, stop it and place it in the background using Ctrl + Z. To run a program directly in the background, add an ampersand (&) at the end of the command, as follows:

find /usr > /tmp/allusrfiles &

Note down the job number and process ID. Keep in mind that you can’t run commands that require terminal input in the background.

You can use the jobs command to display all the programs/commands running in the background or the ones that you stopped (using Ctrl + Z).

Jobs Command

How to Resume Foreground and Background Processes

To continue a job you put in the background, use the fg command, and it will bring the command to the foreground.

fg %<job-number>

Similarly, if you stopped a command from running in the background, you can restart it again in the background using the bg command, as follows:

bg %<job_number>

Killing Processes on Linux

Just as a graphical tool like System Monitor allows you to kill, stop, and continue a process, you can also use command-line tools like kill and killall to send a signal to a running process.

Apart from simply killing a process, the kill command also helps in sending different signals to manage process behaviors.

You can use either names or numbers to use a signal.

kill -signalnumber <process-id>
kill -signalname <process-id>

For example, the following commands send the SIGKILL signal to a process with the PID 1987:

kill -9 1987
kill -SIGKILL 1987

The most commonly used process signals are:

Option Description
SIGKILL (9) Kills the process immediately
SIGTERM (15) Terminates the process
SIGSTOP (19/28/25) Stops the process
SIGCONT (19/28/25) Continues the process after it stops
SIGUP (1) Tells the process to read its configuration file

Note that different processes respond differently to these signals but they cannot stop SIGSTOP and SIGKILL signals. Type the following command to read more about these signals:

man 7 signal

Learn More: How to Terminate Unresponsive Processes in Linux With kill and pkill

Renicing Processes on Linux

The Linux kernel prioritizes running processes and assigns system resources by considering user account privileges. The kernel also considers another factor, which is the “nice” value of every running process.

The default nice value of a process is zero but, you can set the range between -20 to 19. Some facts about setting process priority with nice and renice values are:

  • A process with low nice value has more access to the CPU resources
  • A regular user can only re-prioritize their processes
  • A regular user can only set values between -20 and 19, and can only set a higher value
  • A superuser can set anyone’s processes to any value, high or low

Process Management on Linux Made Easy

A multiuser environment has several processes that require sufficient knowledge of system resource management to prevent bottlenecks and system constraints. Part of the task includes managing processes by running them in the background/foreground, killing or renicing them.

You can also learn about the top command utility to display and sort processes and learn to terminate nonresponding processes on Linux.

7 Ways to Kill Unresponsive Programs in Linux

When a Linux app becomes unresponsive and crashes, how can you kill it? Try one of these tricks to force quit a program in Linux.

Read Next

About The Author


Source link

Leave A Reply

Your email address will not be published.