Inspect background jobs managed by the current shell, including their process IDs.
Which command is appropriate?
jobs -l lists the current shell's jobs and includes their process IDs. ps has a broader process scope.
Detailed explanation
ps --shell-onlyIncorrect. ps has no standard --shell-only option for this task.
Incorrect. ps has no standard --shell-only option for this task.
bg -lIncorrect. bg resumes a job; it does not list jobs.
Incorrect. bg resumes a job; it does not list jobs.
jobs -lCorrect. jobs -l shows job entries with PIDs.
Correct. jobs -l shows job entries with PIDs.
fg -pIncorrect. fg moves a job to the foreground.
Incorrect. fg moves a job to the foreground.
Try it yourself
An example you can run in a temporary verification environment.
help jobsExpected result
Bash builtin jobsと-l optionのhelpKey points
- jobs -l
- Job ID
- PID
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.