0
0
Linux CLIscripting~20 mins

jobs command in Linux CLI - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Jobs Command Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
Output of jobs command with background processes
You run these commands in a Linux shell:
sleep 30 &
sleep 40 &
jobs

What is the expected output of the jobs command?
A
[1]-  Running                 sleep 30 &
[2]+  Running                 sleep 40 &
BNo output, jobs command shows nothing
C
[1]+  Done                    sleep 30 &
[2]-  Done                    sleep 40 &
D
[1]+  Running                 sleep 30 &
[2]-  Running                 sleep 40 &
Attempts:
2 left
💡 Hint
Jobs are numbered in order started; the last job is marked with a plus (+).
💻 Command Output
intermediate
2:00remaining
Effect of fg command on jobs
You start a background job:
sleep 60 &

Then run jobs and see:
[1]+  Running                 sleep 60 &

What happens when you run fg %1?
ASyntax error: fg requires a job name, not a number
BThe sleep 60 job is terminated immediately
CNothing happens, job stays in background
DThe sleep 60 job moves to foreground and blocks the shell until it finishes
Attempts:
2 left
💡 Hint
The fg command brings a background job to foreground.
🔧 Debug
advanced
2:00remaining
Why does jobs show no output?
You run this sequence:
sleep 20 &
jobs

But jobs shows no output. What is the most likely reason?
AThe jobs command requires root privileges
BThe sleep command finished before jobs was run
CThe shell session is not interactive, so jobs command shows nothing
DThe sleep command was run in foreground, so no jobs exist
Attempts:
2 left
💡 Hint
Jobs only work in interactive shells.
🧠 Conceptual
advanced
2: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?
AThe job continues running in background, jobs shows 'Running'
BThe job is suspended (stopped), and jobs shows it as 'Stopped'
CThe job is terminated, and jobs shows no entry
DThe job is paused but jobs shows 'Done'
Attempts:
2 left
💡 Hint
Ctrl+Z sends SIGTSTP to suspend the job.
🚀 Application
expert
3:00remaining
Counting background jobs with jobs command
You run multiple background jobs:
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.
Ajobs | grep Running | wc -l
Bjobs -p | wc -l
Cjobs | wc -l
Dps aux | grep sleep | wc -l
Attempts:
2 left
💡 Hint
Filter jobs output for Running status, then count lines.