Interactive Bash job number 1 is running in the background.
Move that same job to the foreground and give it terminal control.
Which command is appropriate?
fg with a job specification moves that job to the foreground. %1 denotes job number 1.
Detailed explanation
jobs %1Incorrect. jobs lists the job but does not move it.
Incorrect. jobs lists the job but does not move it.
bg %1Incorrect. bg resumes or continues a job in the background.
Incorrect. bg resumes or continues a job in the background.
fg %1Correct. fg %1 brings job 1 to the foreground.
Correct. fg %1 brings job 1 to the foreground.
kill %1Incorrect. kill sends a signal; it does not transfer terminal control.
Incorrect. kill sends a signal; it does not transfer terminal control.
Try it yourself
An example you can run in a temporary verification environment.
対話的Bashで sleep 30 & を実行後、fg %1 を実行して確認Expected result
sleepがフォアグラウンドジョブとなり、Bashは完了まで待つKey points
- fg moves a job to the foreground
- %N is a job specification
- The foreground job receives terminal control
Notes
- Environment: 対話的Bash 5.2
- 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.