The bg command is used to move and resume in the background the last stopped shell job. A stopped job is a process that has been suspended by using Ctrl+Z or the kill -STOP command. The bg command will resume the execution of the stopped job and allow it to run in the background, without blocking the current shell. The bg command can also take a job number as an argument, which can be obtained by using the jobs command. For example, if the last stopped job is 1+ Stopped sleep 500, then the following command will move and resume it in the background:
bg %1
The output will be:
1+ sleep 500 &
The fg command is used to move and resume in the foreground the last stopped or backgrounded job. The run and back commands are not valid commands in Linux. References:
[LPI Exam 101 Detailed Objectives], Topic 103: GNU and Unix Commands, Objective 103.5: Create, monitor and kill processes, Weight: 4, Key Knowledge Areas: Use of jobs, fg and bg commands.
Linux Commands: jobs, bg, and fg, Topic: The bg Command.
Contribute your Thoughts:
Chosen Answer:
This is a voting comment (?). You can switch to a simple comment. It is better to Upvote an existing comment if you don't have anything to add.
Submit