jobs

shellLinux/Unix
The jobs command is one of the most frequently used commands in Linux/Unix-like operating systems. jobs Display status of jobs in the current shell session

Quick Reference

Command Name:

jobs

Category:

shell

Platform:

Linux/Unix

Basic Usage:

jobs [options] [arguments]

Common Use Cases

    Syntax

    jobs [-lnprs] [jobspec]

    Options

    Option Description
    -l List process IDs in addition to the normal information
    -n Display only jobs that have changed status since last notification
    -p List only the process IDs
    -r Restrict output to running jobs
    -s Restrict output to stopped jobs
    jobspec Specify the job for which to show information (e.g., %1 for job 1)

    Examples

    How to Use These Examples

    The examples below show common ways to use the jobs command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.

    # Basic Examples Basic
    jobs
    List all jobs running in the background.
    jobs -l
    List all jobs with process IDs.
    # Advanced Examples Advanced
    jobs -p Display only process IDs of the jobs. jobs %1 Display information about job number 1. jobs -r Display only running jobs. jobs -s Display only stopped jobs. jobs -n Display only jobs that have changed status since last notification. fg %2 Bring job number 2 to the foreground (example of using job ID). kill %3 Kill job number 3 (example of using job ID). sleep 100 & Start a sleep command in the background (creates a job).

    Try It Yourself

    Practice makes perfect! The best way to learn is by trying these examples on your own system with real files.

    Understanding Syntax

    Pay attention to the syntax coloring: commands, options, and file paths are highlighted differently.

    Notes

    The jobs command is a shell built-in command that displays the status of jobs that have been started in the current shell session. It's particularly useful in shell scripting and interactive sessions when working with multiple background and suspended processes. Key features of jobs: 1. Background Process Management: jobs allows users to track processes that have been placed in the background using the & operator or suspended using Ctrl+Z. This enables multitasking within a single terminal session. 2. Job Control: In conjunction with commands like fg (foreground), bg (background), and kill, jobs provides a complete job control system, allowing users to manipulate running processes efficiently. 3. Job Status Tracking: The command reports whether jobs are running, stopped, or have changed status since the last notification, providing real-time information about background processes. 4. Process Identification: With options like -l and -p, jobs can display process IDs (PIDs), which are useful for more specific process manipulation with other commands like kill. 5. Selective Reporting: Using options such as -r (running) and -s (stopped), users can filter the output to focus on specific types of jobs, making it easier to manage complex sessions with multiple background processes. 6. Job Specification: Jobs can be referenced by job number (e.g., %1), making it convenient to manage multiple background processes without having to remember their PIDs. Common use cases for jobs include: - Managing multiple file transfers or downloads in the background - Running long data processing tasks while continuing to work in the same terminal - Temporarily suspending a process to run another command, then resuming the original process - Shell scripting scenarios that involve background process management - System administration tasks that require monitoring and controlling multiple processes The jobs command is typically a shell built-in and is available in most UNIX-like shells including bash, zsh, ksh, and tcsh. Its functionality is closely tied to the shell's job control features, and it works in conjunction with other job control commands and signals to provide a comprehensive process management system within the terminal environment. Note that jobs only shows processes started from the current shell session. To see all processes on the system, commands like ps or top should be used instead.

    Related Commands

    These commands are frequently used alongside jobs or serve similar purposes:

    Use Cases

    Learn By Doing

    The best way to learn Linux commands is by practicing. Try out these examples in your terminal to build muscle memory and understand how the jobs command works in different scenarios.

    $ jobs
    View All Commands