Challenge - 5 Problems
Jobs Command Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
Output of jobs command with background processes
You run these commands in a Linux shell:
What is the expected output of the
sleep 30 & sleep 40 & jobs
What is the expected output of the
jobs command?Attempts:
2 left
💡 Hint
Jobs are numbered in order started; the last job is marked with a plus (+).
✗ Incorrect
The jobs command lists background jobs with their job numbers. The most recent job is marked with a plus (+) and the previous with a minus (-). Both sleep commands run in background, so status is Running.
💻 Command Output
intermediate2:00remaining
Effect of fg command on jobs
You start a background job:
Then run
What happens when you run
sleep 60 &
Then run
jobs and see:[1]+ Running sleep 60 &
What happens when you run
fg %1?Attempts:
2 left
💡 Hint
The fg command brings a background job to foreground.
✗ Incorrect
The fg command resumes the specified job in the foreground, so the shell waits until the job completes.
🔧 Debug
advanced2:00remaining
Why does jobs show no output?
You run this sequence:
But
sleep 20 & jobs
But
jobs shows no output. What is the most likely reason?Attempts:
2 left
💡 Hint
Jobs only work in interactive shells.
✗ Incorrect
The jobs command only reports jobs in interactive shells. In scripts or non-interactive shells, it shows nothing.
🧠 Conceptual
advanced2:00remaining
Understanding job control signals
You have a job running in foreground. You press Ctrl+Z. What happens to the job and how does
jobs reflect this?Attempts:
2 left
💡 Hint
Ctrl+Z sends SIGTSTP to suspend the job.
✗ Incorrect
Ctrl+Z suspends the foreground job, stopping it temporarily. The jobs command then lists it as 'Stopped'.
🚀 Application
expert3:00remaining
Counting background jobs with jobs command
You run multiple background jobs:
Write a one-liner command using
sleep 10 & sleep 20 & sleep 30 &
Write a one-liner command using
jobs and other shell tools to count how many background jobs are currently running.Attempts:
2 left
💡 Hint
Filter jobs output for Running status, then count lines.
✗ Incorrect
The command 'jobs | grep Running | wc -l' counts only the lines with 'Running', corresponding to currently running background jobs. Other options may count stopped jobs or unrelated processes.