A process means program in execution. It generally takes an input, processes it and gives us the appropriate output. Check Introduction to Process Management for more details about a process. There are basically 2 types of processes.
- Foreground processes: Such kind of processes are also known as interactive processes. These are the processes which are to be executed or initiated by the user or the programmer, they can not be initialized by system services. Such processes take input from the user and return the output. While these processes are running we can not directly initiate a new process from the same terminal.
- Background processes: Such kind of processes are also known as non interactive processes. These are the processes that are to be executed or initiated by the system itself or by users, though they can even be managed by users. These processes have a unique PID or process if assigned to them and we can initiate other processes within the same terminal from which they are initiated.
Practically Managing the Processes
1. Example of foreground process.
sleep 5

This command will be executed in the terminal and we would be able to execute another command after the execution of the above command.
Note: In this case, the name of the process is sleep 5 but you may change the same as per your need.
2. Stopping a process in between of its execution. To stop a foreground process in between of its execution we may press CTRL+Z to force stop it.
sleep 100

Pressing CTRL+Z in between the execution of the command will stop it.
Note: In this case the name of the process is sleep 100 but you may change the same as per your need.
3. To get the list of jobs that are either running or stopped.
jobs

It will display the stopped processes in this terminal and even the pending ones.
4. To run all the pending and force stopped jobs in the background.
bg

This will start the stopped and pending processes in the background.
5. To get details of a process running in background.
ps -ef | grep sleep

Note: In this case the name of the process is sleep 100 but you may change the same as per your need.
6. To run all the pending and force stopped jobs in the foreground.
fg

This will start the stopped and pending processes in the foreground.
7. To run a process in the background without getting impacted by the closing of the terminal.
nohup sleep 100 &

While executing, it will even store all the output after execution in nohup.out file.
Note: In this case, the process is sleep 100, you may modify it as per your need.
8. To run some processes in the background directly.
sleep 100&

This will run the process in the background and will display the process id of the process.
Note:- In this case, the process is sleep 100, you may modify it as per your need.
9. To run processes with priority.
nice -n 5 sleep 100

The top priority is -20 but as it may affect the system processes so we have used the priority 5.
Note: In this case, the process is sleep 100, you may modify it as per your need.
10. To get the list of all the running processes on your Linux machine.
top

This will display all the processes that are currently running in your system.
Recommended Posts:
- File Management in Linux
- User Management in Linux
- What is init.d in Linux Service Management?
- Group Management in Linux
- Kali Linux - File Management
- Process states and Transitions in a UNIX Process
- Exit status of a child process in Linux
- Priority of process in Linux | nice value
- Getting System and Process Information Using C Programming and Shell in Linux
- Linux Virtualization : Linux Containers (lxc)
- Difference Between Arch Linux and Kali Linux
- Implementing Directory Management using Shell Script
- Maximum number of Zombie process a system can handle
- Maximum number of threads that can be created within a process in C
- Communication between two process using signals in C
- How to find time taken by a command/program on Linux Shell?
- Terminal Mail and Linux Security Mail
- Linux Virtualization - Chroot Jail
- Linux Kernel Module Programming: Hello World Program
- Formatted text in Linux Terminal using Python
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

