A process is an instance of a program currently running in the form of thread(s). Depending on the environment, a process can be uni-threaded (comprising of a single thread) or multithreaded (comprising of multiple threads). A process is an active entity as opposed to a program which is a passive entity.
In Linux, there are various commands which are used for process manipulation. There are commands which enable the user to view the list of processes and their information, commands which allow the user to delay the start of a particular process and commands which terminate or stop a process from further execution. These commands enable the user to manipulate running processes according to his/her needs. All these commands have many options that can be used along with them.
A few commands that are used for process manipulation are:
1. ps - The ps command is used to list all the currently running processes in the system and information related to them. This information consists of the process name, user, memory consumption, CPU consumption, process ID, etc.
2. sleep - The sleep command is used in Linux to delay a running program by a certain amount of time. The amount of time to be delays can be specified in seconds, minutes, hours, and even days. The suffix values for minutes, hours days are m, h, and d respectively. If no suffix value is specified, then, by default, the value is taken in seconds.
If during the sleep period, you hit Ctrl+Z, then the sleep is terminated and the process continues execution.
3. jobs - The jobs command in Linux is used to list the status of all the jobs currently running in the terminal along with their job number. This lists only those processes which started running in this session. Job numbers always start from 1 and are always displayed inside .
There are various options that can be used along with the jobs command such as -n (displays processes whose status has changed after the previous check), -p (lists only the process IDs), etc.
4. bg - The bg command is used to push a suspended process into the background where it can continue to run. The syntax for this command is bg %n where n is the job number of the suspended process the user wants to push to the background.
5. fg - Similar to the bg command, the fg command is used to bring back a suspended process in the background to the foreground. The syntax for this command is fg %n where n is the job number of the suspended process the user wants to push to the background. To kill a process running in the foreground, Ctrl + C can be used.
6. kill - The kill command in Linux is used to kill or stop a currently running process. The kill command can be used both with the job number and the Process ID (or PID).
The syntax to kill a process with its job number is kill %n where n is the job number.
The syntax to kill a process with its Process ID is kill -9 n where n is the Process ID.
This command also has many options that can be used along with it.
|Usermod command in Linux||4513||1|
|SSH Command In Linux||788||7|
|Introduction to Named Pipes||1058||3|
|Linux KILL Command||2783||5|
|Soft Link and Hard Link In Linux||421||2|
|Vi Editor in Linux||594||6|
|FDisk Command in Linux||540||5|
|How to view the History in Linux||448||2|
|Process Manipulation in Linux||1615||4|
|Export command in Linux||411||1|
|ID command in Linux||413||1|
|Netstat Command in Linux||624||3|
|Chmod Command in Linux||437||1|
|Compressing Files in Linux||355||1|
|Crontab in Linux||477||1|
|File Manipulation in Linux||615||5|
|Curl Command in Linux||505||1|
|Env Command in Linux||398||5|
|LSOF Command in Linux||406||1|
|User Manual in Linux||433||1|
|Whereis command in Linux||437||1|
|4 Lesser Known Commands in Linux||468||6|
|Shell Scripting in Linux||632||4|
|Alias command in Linux||373||1|
|How to Kill a Process using Command Line||471||3|