Challenge - 5 Problems
Background Process Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate1:30remaining
What is the output of this command sequence?
Consider the following commands run in a Linux shell:
What will be printed immediately after running these commands?
sleep 2 & echo DoneWhat will be printed immediately after running these commands?
Linux CLI
sleep 2 & echo DoneAttempts:
2 left
💡 Hint
The ampersand (&) runs the first command in the background, so the shell does not wait for it.
✗ Incorrect
The 'sleep 2 &' runs the sleep command in the background, so the shell immediately runs 'echo Done' and prints 'Done' right away.
💻 Command Output
intermediate2:00remaining
What happens when you run multiple background jobs?
You run these commands in a Linux shell:
What will happen after running these commands?
sleep 3 & sleep 1 & sleep 2 & waitWhat will happen after running these commands?
Linux CLI
sleep 3 & sleep 1 & sleep 2 & wait
Attempts:
2 left
💡 Hint
The 'wait' command waits for all background jobs to finish.
✗ Incorrect
All three sleep commands run in background because of '&'. The 'wait' command pauses the shell until all background jobs complete.
🔧 Debug
advanced1:30remaining
Why does this background command fail to run properly?
You try to run this command in a shell:
What error will the shell produce?
echo Hello & & echo WorldWhat error will the shell produce?
Linux CLI
echo Hello & & echo World
Attempts:
2 left
💡 Hint
Check how many ampersands are used and their placement.
✗ Incorrect
The shell sees two ampersands in a row without a command between them, causing a syntax error.
🚀 Application
advanced2:00remaining
How to run a script in background and save its output to a file?
You want to run a script named
backup.sh in the background and save both its output and errors to backup.log. Which command does this correctly?Attempts:
2 left
💡 Hint
Redirect output before putting command in background.
✗ Incorrect
The correct syntax redirects stdout and stderr to the file, then runs the command in background with '&'.
🧠 Conceptual
expert2:00remaining
What is the effect of running a command with nohup and & together?
You run this command:
What happens to the process if you close the terminal?
nohup longtask.sh &What happens to the process if you close the terminal?
Attempts:
2 left
💡 Hint
nohup prevents hangup signals from stopping the process.
✗ Incorrect
nohup makes the process ignore hangup signals, so combined with '&' it runs in background and keeps running after terminal closes.