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.
jobs %2Incorrect. jobs lists state but does not change foreground ownership.
wait %2Incorrect. wait waits for completion and does not attach the terminal.
fg %2Correct. 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
- Use a disposable process or test shell when checking lifecycle commands.
- Exact output and option names can vary slightly by distribution and tool version.
Foundation review
Place the operation
fg differs from bg because it attaches the job to terminal input and makes the shell wait.
Check the side effect
Check the job number in jobs output before passing a job specification to fg.