Challenge - 5 Problems
Job Control Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
What is the output of this sequence of commands?
You run the following commands in a Linux shell:
What will the
sleep 30 &
jobs
fg %1What will the
jobs command output before fg %1 is run?Linux CLI
sleep 30 & jobs fg %1
Attempts:
2 left
💡 Hint
Think about what happens when a command is run in the background with & and how jobs lists them.
✗ Incorrect
When you run 'sleep 30 &' the job runs in the background and is marked as 'Running'. The jobs command shows it with a plus sign for the current job and the '&' indicates background.
💻 Command Output
intermediate2:00remaining
What happens after running bg on a stopped job?
You start a command and stop it with Ctrl+Z. Then you run
bg %1. What will be the job status if you run jobs immediately after?Linux CLI
sleep 30 # Press Ctrl+Z to stop bg %1 jobs
Attempts:
2 left
💡 Hint
bg resumes a stopped job in the background.
✗ Incorrect
The bg command resumes the stopped job in the background, so jobs will show it as Running with an ampersand.
📝 Syntax
advanced2:00remaining
Which command correctly brings job 2 to the foreground?
You have multiple jobs running. Which of these commands correctly brings job number 2 to the foreground?
Attempts:
2 left
💡 Hint
Jobs are referenced by a percent sign followed by the job number.
✗ Incorrect
The correct syntax to bring job number 2 to foreground is 'fg %2'. 'fg 2' is invalid because it lacks the percent sign. 'fg job2' and 'fg #2' are invalid syntaxes.
🔧 Debug
advanced2:00remaining
Why does this bg command fail with 'no such job' error?
You run:
But get the error: 'bg: no such job'. Why?
sleep 100 &
bg %1But get the error: 'bg: no such job'. Why?
Linux CLI
sleep 100 & bg %1
Attempts:
2 left
💡 Hint
bg only works on stopped jobs.
✗ Incorrect
The bg command resumes stopped jobs in the background. If the job is already running, bg cannot resume it and gives 'no such job' error.
🚀 Application
expert2:00remaining
How to bring the most recent stopped job to foreground using a single command?
You have multiple jobs stopped and running. Which command brings the most recent stopped job to the foreground?
Attempts:
2 left
💡 Hint
The %+ symbol refers to the current job.
✗ Incorrect
In job control, '%+' refers to the current job, which is usually the most recent stopped or background job. Using 'fg %+' brings it to foreground.