Controlling processes is a fundamental skill for Linux users and administrators, allowing them to manage system resources effectively, enhance system performance, and maintain system security. A “process” in Linux is a running instance of a program, and controlling it refers to starting, stopping, pausing, and managing these processes, either in the foreground or in the background. Efficient process control is crucial to optimize the performance of the Linux system, especially in multi-user or high-demand environments.
Starting a Process
Initiating a process in Linux is as simple as running a command or a program.
gedit can be started from the command line by typing the
following command and pressing Enter:
## Starts gedit in the forground
## Adds gedit in the background
$ gedit &
When started this way,
gedit runs in the foreground, blocking the terminal
from which it was started for further input until the process is stopped or sent
to the background.
Understanding Background Processes
When a process is started, it’s typically run in the foreground, occupying the terminal until it completes. While a process is running in the foreground, the terminal is blocked, and you can’t use it to run other commands until the process completes.
In contrast, a background process runs without occupying the terminal, allowing the user to continue running other commands and managing other tasks from the same terminal. This enables multitasking and allows for more efficient use of system resources.
Checking if a Process is Running in Foreground or Background
To determine whether a process is running in the foreground or the background,
you can examine the process status using the
This command lists all jobs started in the current shell, showing their status ( running, stopped, or done) and whether they are running in the foreground or the background.
For example, if
gedit is running in the background, executing
jobs will show
+ Running gedit &
1 is the job ID, and
gedit is the process running in the background.
+ sign indicates that this is the current (or most recently used) job,
& denotes that the process is running in the background.
Bring Job to Foreground
To bring a background process to the foreground, use the
fg command followed
by the job ID:
$ fg 1
After executing this command, the
gedit process, in this case, will be moved
to the foreground, allowing you to interact with it directly from the terminal.
Sending a Process to the Background
To send a foreground process like
gedit to the background, first, suspend it
Ctrl + Z, then use the
$ bg %1
Managing Processes: Stop, Pause, and Terminate
Managing processes efficiently is a crucial aspect of Linux administration. There are different commands and signals available to control the execution states of a process, such as stopping, pausing, or terminating it.
Starting a Process
For illustration, let’s start a
Identifying Process Information
You can identify the Process ID (PID) of the
gedit process by using the
$ ps aux | grep gedit
A process in Linux can exist in several states including Running, Stopped, or Terminated. Here's a simplified table to understand these states:
|The process is either running or it is ready to run.
|The process is stopped and can be restarted by the user.
|The process has been terminated, either by user command or by the system.
Managing Process States
1. Stopping a Process
To stop a process means to put it in a state where it is paused and can be
resumed later. You can stop the
gedit process by sending a
$ kill -SIGSTOP [PID]
[PID] with the actual PID of the
2. Continuing a Stopped Process
You can continue a stopped process using the
$ kill -SIGCONT [PID]
3. Terminating a Process
To terminate a process means to kill it. You can terminate the
$ kill -SIGTERM [PID]
Monitoring Processes with
For real-time process monitoring,
htop are invaluable tools,
providing detailed, dynamic views of system activity and process status:
Controlling and managing processes are crucial skills when working with Linux.
Whether you're using
gedit or any other program, understanding how to start,
stop, pause, resume, and monitor processes from the command line is essential
for effective system administration and usage.
Remember to replace
[PID] with the actual Process ID of the
[nice_value] with the desired nice value when experimenting with these
commands. Always exercise caution, particularly with the
kill command, to
avoid inadvertently terminating essential system processes.
What Can You Do Next 🙏😊
If you liked the article, consider subscribing to Cloudaffle, my YouTube Channel, where I keep posting in-depth tutorials and all edutainment stuff for software developers.