What does the ampersand (&) symbol do when added at the end of a command in Linux?
It runs the command as a background process, allowing you to continue using the terminal without waiting for the command to finish.
Click to reveal answer
beginner
How can you check the list of background jobs running in your current shell session?
Use the jobs command to see all background jobs with their job numbers and statuses.
Click to reveal answer
beginner
What command brings a background job back to the foreground?
Use fg %job_number to bring a specific background job to the foreground.
Click to reveal answer
beginner
Why would you want to run a process in the background?
To keep the terminal free for other commands while a long-running task continues without blocking your work.
Click to reveal answer
intermediate
What happens if you close the terminal while a background process is running?
The background process usually stops unless it was started with tools like nohup or inside a terminal multiplexer like screen or tmux.
Click to reveal answer
What does adding '&' at the end of a command do?
ARuns the command in the background
BStops the command immediately
CRuns the command with higher priority
DRuns the command in a new terminal window
✗ Incorrect
The '&' symbol runs the command as a background process, freeing the terminal for other commands.
Which command lists all background jobs in the current shell?
Ajobs
Bps
Cbg
Dfg
✗ Incorrect
The 'jobs' command shows all background jobs with their status.
How do you bring a background job with job number 2 to the foreground?
Ajobs %2
Bbg %2
Cfg %2
Dkill %2
✗ Incorrect
The 'fg %2' command brings job number 2 to the foreground.
What happens to background processes if you close the terminal without precautions?
AThey keep running forever
BThey stop running
CThey restart automatically
DThey become foreground processes
✗ Incorrect
Closing the terminal usually stops background processes unless special tools are used.
Which tool can keep a process running after terminal closes?
Ajobs
Bfg
Ckill
Dnohup
✗ Incorrect
'nohup' allows a process to continue running after the terminal is closed.
Explain how to run a command in the background and how to check its status.
Think about how to free your terminal while a task runs.
You got /2 concepts.
Describe how to bring a background process back to the foreground and why you might want to do that.
Remember the command that resumes control of a background job.
You got /2 concepts.
Practice
(1/5)
1. What does adding & at the end of a command in Linux do?
easy
A. Runs the command with higher priority
B. Stops the command from running
C. Runs the command in the background, freeing the terminal immediately
D. Saves the command output to a file
Solution
Step 1: Understand the role of & in Linux commands
Adding & at the end of a command tells the shell to run it in the background.
Step 2: Effect on terminal usability
Running a command in the background frees the terminal immediately for other commands.
Final Answer:
Runs the command in the background, freeing the terminal immediately -> Option C
Quick Check:
Background process = command + & [OK]
Hint: Remember: & means run in background [OK]
Common Mistakes:
Thinking & stops the command
Confusing & with output redirection
Assuming & increases priority
2. Which of the following is the correct syntax to run sleep 10 in the background?
easy
A. sleep & 10
B. & sleep 10
C. sleep 10 &&
D. sleep 10 &
Solution
Step 1: Identify correct placement of &
The & must be at the end of the command to run it in the background.
Step 2: Check each option
sleep 10 & places & correctly after sleep 10. Others place it incorrectly or use wrong syntax.
Final Answer:
sleep 10 & -> Option D
Quick Check:
Command + & at end = background run [OK]
Hint: Put & at the end of the command [OK]
Common Mistakes:
Placing & before the command
Using && instead of &
Splitting & from command arguments
3. What will be the output after running these commands?
sleep 5 &
jobs
medium
A. Immediately exits the terminal
B. Lists the sleep job running in the background
C. Displays an error about sleep command
D. Shows no jobs running
Solution
Step 1: Run sleep 5 &
This starts the sleep command in the background for 5 seconds.
Step 2: Run jobs
This command lists all background jobs currently running, including the sleep job.
Final Answer:
Lists the sleep job running in the background -> Option B
Quick Check:
jobs shows background tasks [OK]
Hint: Use jobs to see background tasks [OK]
Common Mistakes:
Expecting jobs to show nothing
Confusing jobs with ps command
Thinking sleep runs in foreground without &
4. You ran sleep 10 & but the job does not appear when you run jobs. What is the likely problem?
medium
A. You ran the command in a different shell session
B. The sleep command does not support background execution
C. You forgot to add & at the end
D. The jobs command is not installed
Solution
Step 1: Understand job control scope
Background jobs are tracked per shell session. Running jobs in a different session won't show jobs from another.
Step 2: Check other options
Sleep supports background execution, & was used, and jobs is a built-in command, so those are unlikely issues.
Final Answer:
You ran the command in a different shell session -> Option A
Quick Check:
jobs show current shell's background tasks only [OK]
Hint: jobs only shows current shell's background tasks [OK]
Common Mistakes:
Assuming jobs shows all system background tasks
Thinking sleep can't run in background
Believing jobs is an external command
5. You want to run a script backup.sh in the background and bring it to the foreground later. Which sequence of commands is correct?
hard
A. ./backup.sh & fg %1
B. ./backup.sh && fg
C. ./backup.sh & jobs; fg %2
D. ./backup.sh & bg %1
Solution
Step 1: Run the script in background
Use ./backup.sh & to start the script in the background.
Step 2: Bring the background job to foreground
Use fg %1 to bring job number 1 (the backup script) to the foreground.
Step 3: Analyze options
./backup.sh & fg %1 correctly runs the script in background and then brings job 1 to foreground. ./backup.sh && fg uses logical && instead of &, so runs in foreground. ./backup.sh & jobs; fg %2 uses wrong job number %2. ./backup.sh & bg %1 uses bg which resumes background jobs, not foreground.
Final Answer:
./backup.sh & fg %1 -> Option A
Quick Check:
Run with & then fg %job_number to foreground [OK]
Hint: Use fg %job_number to bring background job forward [OK]
Common Mistakes:
Using && instead of & for background
Using bg instead of fg to foreground
Using wrong job number like %2
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.