Skip to content

jobs Linux command

The Linux jobs command is a useful tool for managing background jobs within a terminal session. This command allows users to monitor, control, and manipulate processes that are running in the background. By using the jobs command, users can view a list of all active background jobs, along with their respective job IDs. This makes it easier to keep track of multiple processes running simultaneously and allows users to bring jobs to the foreground or background, as needed. Additionally, the jobs command provides options for manipulating the status of jobs, such as suspending or resuming them. This can help users efficiently manage their workflow and ensure that all processes are running smoothly.

jobs Syntax:

Terminal window
jobs [options] [parameters]

Options:

OptionDescription
-lList process IDs in addition to job IDs
-pDisplay process group IDs
-rDisplay only running jobs
-sDisplay only stopped jobs
-nDisplay only jobs that have changed status since the last notification
-xDisplay only jobs that have not been started

Parameters:

ParameterDescription
job_specSpecify the job or process to act upon
commandSpecify the command to execute and put in the background

jobs bash Examples:

List all current jobs

Terminal window
jobs

Displays all current jobs running in the background.

Run a command in the background

Terminal window
sleep 10 &

Executes the command “sleep 10” in the background, allowing you to continue using the terminal.

Bring a background job to the foreground

Terminal window
fg %1

Brings the first background job to the foreground.

Suspend a foreground job

Terminal window
Ctrl + Z

Suspends the currently running foreground job.

Resume a suspended job in the foreground

Terminal window
bg %1

Resumes the first suspended job in the background.

Kill a specific job

Terminal window
kill %1

Immediately terminates the first running job in the background.

How do I use jobs in Linux?

To use the jobs command in Linux, execute the following command:

Terminal window
jobs

How can I list all jobs in the current shell session?

To list all jobs in the current shell session, you can use the jobs command with the -l option:

Terminal window
jobs -l

How can I bring a job to the foreground in Linux?

To bring a job to the foreground in Linux, you can use the fg command followed by the job number. For example:

Terminal window
fg %1

How can I send a job to the background in Linux?

To send a job to the background in Linux, you can use the bg command followed by the job number. For example:

Terminal window
bg %1

How do I display the process IDs of background jobs in Linux?

To display the process IDs of background jobs in Linux, you can use the jobs command with the -p option. For example:

Terminal window
jobs -p

How can I kill a background job in Linux?

To kill a background job in Linux, you can use the kill command with the process ID of the job. For example:

Terminal window
kill %1

How do I resume a suspended job in Linux?

To resume a suspended job in Linux, you can use the fg command followed by the job number. For example:

Terminal window
fg %1

Applications of the jobs command

  • View a list of current jobs running in the background
  • Manage background processes by bringing them to the foreground or sending them to the background
  • Check the status of background jobs and their job numbers
  • Resume suspended jobs in the terminal