The jobs
command in Bash is used to display the status of jobs that are running in the background or have been stopped in the current shell session. It provides information about each job, including its job number, status, and command line.
The basic syntax of the jobs
command is as follows:
jobs [options]
-l
: Show the process IDs (PIDs) of the jobs.-n
: Show only jobs that have changed status since the last notification.-p
: Display only the process IDs of the jobs.To see the list of current jobs running in the background:
jobs
To display the jobs along with their process IDs:
jobs -l
To show only jobs that have changed status since the last command:
jobs -n
To list only the process IDs of the jobs:
jobs -p
bg %job_number
to resume a stopped job in the background.fg %job_number
to bring a background job to the foreground.