Last Updated : 18 Mar, 2021
Process control commands in Unix are:bg - put suspended process into background fg - bring process into foreground jobs - list processes
bg [job]
Options
The character % introduces a job specification. The Job can be a process ID (PID) number, or we can use one of the following symbol combinations:%Number : Use the job number such as %1 or %2. %String : Use the string whose name begins with suspended command such as %commandNameHere or %ping. %+ OR %% : Refers to the current job. %- : Refers to the previous job.
bg examples
Commandbg %1Output:
The stopped job will resume operation, but remain in the background. It will not receive any input from the terminal while it's in the background, but it will keep running.
fg [ %job]
Options
%job: Specifies the job that you want to run in the foreground.
fg examples
Command$ fgOutput:
It will resume the most recently suspended or background job.Command
$ fg 1Output:
It brings the job with the id 1 into the foreground, resuming it if it was suspended.
jobs [JOB]
Options
JOB Job name or number. -l Lists process IDs in addition to the normal information. -n List only processes that have changed status since the last notification. -p Lists process IDs only. -r Restrict output to running jobs. -s Restrict output to stopped jobs.
jobs command examples
To display the status of jobs in the current shell: Command$ jobsOutput:
[1] 7893 Running gpass & [2] 7904 Running gnome-calculator & [3]- 7955 Running gedit fetch-stock-prices.py & [4]+ 7958 Stopped ping cyberciti.bizTo display the process ID or jobs for the job whose name begins with “p,”: Command
$ jobs -p %pOR
$ jobs %pOutput:
[4]- Stopped ping cyberciti.bizThe character % introduces a job specification. In this example, you are using the string whose name begins with suspended command such as %ping. Pass the -p option to jobs command to display PIDs only: Command
$ jobs -pOutput:
7895 7906 7910 7946Pass the -r option to jobs command to display only running jobs only: Command
$ jobs -rOutput:
[1] Running gpass & [2] Running gnome-calculator & [3]- Running gedit fetch-stock-prices.py &
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4