bg
Overview
The bg
command resumes suspended jobs in the background. It continues a stopped job by running it in the background.
Syntax
bg [jobspec...]
Common Options
Option | Description |
---|---|
-h |
Show help |
-v |
Show version |
Job Specification
Spec | Description |
---|---|
%n | Job number n |
%str | Job starting with str |
%?str | Job containing str |
%+ | Current job |
%- | Previous job |
%% | Current job |
Key Use Cases
- Resume jobs
- Background processing
- Task management
- Shell control
- Process handling
Examples with Explanations
Example 1: Current Job
bg
Resume current job
Example 2: Specific Job
bg %2
Resume job number 2
Example 3: Multiple Jobs
bg %3 %4
Resume multiple jobs
Common Usage Patterns
Stop then background:
Ctrl-Z bg
Specific job:
bg %jobid
Check status:
bg; jobs
Job Control
- Stop (Ctrl-Z)
- Background (bg)
- Foreground (fg)
- List (jobs)
- Kill (kill)
Additional Resources
Best Practices
- Check job status
- Use job numbers
- Monitor output
- Clean up jobs
- Document usage
Security Considerations
- Job ownership
- Process control
- Resource usage
- Shell access
- User permissions
Troubleshooting
- Job status
- Process state
- Shell issues
- Resource limits
- Output handling
Common Scenarios
- Long processes
- Multiple tasks
- Shell scripts
- System tasks
- User processes