Linux Jobs Command
The jobs command in Linux is a powerful shell built-in
utility used to display the status of jobs (processes) that are
currently running in the background in your current shell session.
This is incredibly useful for managing multiple tasks without
blocking your terminal. Understanding how to use
jobs effectively can significantly improve your
command-line productivity.
View All Background Jobs
To see all background running commands, simply type
jobs:
jobs
This command will list all jobs, indicating whether they are running, stopped, or completed. Each job is typically prefixed with a job number.
View Jobs with Process IDs (PIDs)
Often, you need the Process ID (PID) to interact with a specific
process using other commands like kill. The
-l option displays the PID alongside the job number and
status:
jobs -l
This is crucial for precise process management.
View Only Running Jobs
If you are only interested in processes that are actively running in
the background, use the -r option:
jobs -r
This filters out any stopped or completed jobs, showing only those currently executing.
View Only Stopped Jobs
Conversely, to see jobs that have been stopped (e.g., by pressing
Ctrl+Z) but not yet terminated, use the
-s option:
jobs -s
This helps you identify processes that you might want to resume later.