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

  1. Resume jobs
  2. Background processing
  3. Task management
  4. Shell control
  5. 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

  1. Stop then background:

    Ctrl-Z
    bg
  2. Specific job:

    bg %jobid
  3. Check status:

    bg; jobs

Job Control

  1. Stop (Ctrl-Z)
  2. Background (bg)
  3. Foreground (fg)
  4. List (jobs)
  5. Kill (kill)

Additional Resources

Best Practices

  1. Check job status
  2. Use job numbers
  3. Monitor output
  4. Clean up jobs
  5. Document usage

Security Considerations

  1. Job ownership
  2. Process control
  3. Resource usage
  4. Shell access
  5. User permissions

Troubleshooting

  1. Job status
  2. Process state
  3. Shell issues
  4. Resource limits
  5. Output handling

Common Scenarios

  1. Long processes
  2. Multiple tasks
  3. Shell scripts
  4. System tasks
  5. User processes