GO KALI FREE
Process Commands

bg Linux Command

Resumes a suspended job in the background.

What does bg do?

Resumes a suspended job in the background.

Syntax

bg [job_id]

Practical example

bg %1

Questions about bg

How do I resume a suspended job in the background?

Use `bg %jobid` to resume a suspended job in the background. Without a job ID, it resumes the most recently suspended job.

How do I suspend a running job?

Press `Ctrl+Z` to suspend the currently running job. Then use `bg` to resume it in the background.

How do I see background jobs?

Use `jobs -l` to list all jobs with their job IDs, PIDs, and status. The `+` indicates the current job, `-` the previous.

How do I bring a background job to the foreground?

Use `fg %jobid` to bring a background job to the foreground. Without a job ID, it brings the most recent background job.

What is the difference between bg and nohup?

`bg` resumes a suspended job in the background. `nohup` runs a command immune to hangups from the start. Use `nohup command &` for persistent background processes.

How do I run a command directly in the background?

Append `&` to any command: `command &`. The job is immediately placed in the background with a job ID.

How do I run a job in the background and disown it?

Use `command &` then `disown %jobid` to remove the job from the shell's job table. This prevents SIGHUP on shell exit.

How do I stop a background job?

Use `kill %jobid` to stop a background job, or `kill $(jobs -p)` to kill all background jobs of the current shell.

Related Process Commands

pkill

Sends a signal to processes based on name and other attributes.

fg

Brings a background job to the foreground.

killall

Kills all processes matching a given name.

jobs

Lists active jobs (background and suspended processes) in the current shell.

kill

Sends a signal to terminate a process by its PID.

nice

Runs a command with a specified scheduling priority (niceness value).