The background process appears as job 2 in jobs.
Bring it to the terminal foreground for interaction.
Which command is appropriate?
fg %2 moves job 2 to the foreground. A shell job number is distinct from a process ID.
Detailed explanation
bg %2Incorrect. bg resumes a stopped job in the background.
Incorrect. bg resumes a stopped job in the background.
jobs %2Incorrect. jobs lists state but does not change foreground ownership.
Incorrect. jobs lists state but does not change foreground ownership.
wait %2Incorrect. wait waits for completion and does not attach the terminal.
Incorrect. wait waits for completion and does not attach the terminal.
fg %2Correct. fg %2 moves job 2 to the foreground.
Correct. fg %2 moves job 2 to the foreground.
Try it yourself
An example you can run in a temporary verification environment.
help fgExpected result
Bash builtin fgのhelpKey points
- fg
- %2
- Foreground process group
Notes
- Environment: Bash 5.x builtin help
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Read the scope first
Check whether the command acts on the current shell, a new process, an existing process, or a file.
Verify the observable result
Use the supplied command and compare the output with the expected result.