Linux / Unix: jobs Command Examples

The jobs command in Linux and Unix displays information about the jobs that are running in the background or stopped in the current shell. Here are some examples of how to use the jobs command:

  1. Display all jobs in the current shell:
    jobs
  2. Display the status of a specific job:
    jobs -l [job_number]
  3. Display the process ID of a specific job:
    jobs -p [job_number]
  4. Display the command line of a specific job:
    jobs -x [job_number]

Where [job_number] is the number of the job you want to display information about. The job numbers can be found by running the jobs command without any options.

You can also use the % symbol to refer to a job, for example:

fg %[job_number]

will bring the specified job to the foreground.

Note that the jobs command is used in conjunction with job control commands such as fg, bg, and kill to manage background and foreground jobs in a shell.

Leave a Comment