Linux Job Basics
What is a Linux Job?
In Linux, a job is a process that is running in the background or foreground of the terminal. When you execute a command or run a script, it becomes a job that can be managed and controlled by the system.
Job States
Linux jobs can exist in different states:
State |
Description |
Running |
Currently executing |
Stopped |
Paused and not running |
Background |
Running without terminal control |
Foreground |
Directly interacting with the terminal |
Job Identification
graph TD
A[Job Creation] --> B[Assigned Job ID]
B --> C[Process ID - PID]
B --> D[Job Number in Terminal]
Jobs are identified by:
- Process ID (PID)
- Job Number
- Command name
Creating Jobs
Foreground Jobs
By default, commands run in the foreground:
$ ls
## Runs directly in the terminal
Background Jobs
To run a job in the background, use &
:
$ sleep 100 &
[1] 12345 ## Job number and PID
Job Control Basics
Ctrl + Z
: Suspend current job
Ctrl + C
: Terminate current job
&
: Run job in background
jobs
: List current jobs
LabEx Tip
When learning job management, LabEx provides interactive Linux environments to practice these concepts hands-on.