bg Linux Commands
What is Linux bg Command?
Explanation
bg COMMAND:bg command is used to place a job in background. User can run a job in the background by adding a "&" symbol at the end of the command.
SYNTAX :
bg [options] [job]
OPTIONS:
-l |
Report the process group ID and working directory of the jobs. |
-p |
Report only the process group ID of the jobs. |
-x |
Replace any job_id found in command or arguments with the corresponding process group ID, then execute command passing it arguments. |
job |
Specifies the job that want to run in the background. |
EXAMPLE:
- To Run a process in background
kmail- start the email client application.
Press ctrl+z to stop the current job.
Now just type bg to move last stopped job to background.
- To move the specified job to back ground:
Lets start some three jobs and suspend those process in background.
kmail- start the email client application.
Press ctrl+z to stop the current job.
xmms- music player application.
Press ctrl+z to stop the current job.
sleep 120- a dummy job.
Press ctrl+z to stop the current job.
jobs
The above command will display the jobs in the shell.
[1]
Stopped
kmail
[2]- Stopped
xmms
[3]+ Stopped
sleep 120
bg 2
The above command will start running the xmms application. In such way you can start running the specific background process.
jobs
[1]- Stopped
kmail
[2]
Running
xmms &
[3]+ Stopped
sleep 120