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.
bg -lIncorrect. bg resumes a job; it does not list jobs.
jobs -lCorrect. jobs -l shows job entries with PIDs.
fg -pIncorrect. 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
- 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
The jobs table is scoped to one shell; it is not a complete process snapshot for the operating system.
Check the side effect
Use ps when the investigation needs processes launched by other shells or users.