Linux / Unix: bg Command Examples

Linux / Unix: bg Command Examples

The bg command is a shell command that is used to run a job in the background in a Unix or Linux system.

When you run a job in the background, it continues to run in the background even after you log out of the system or close the terminal. This allows you to run long-running tasks or processes without tying up the terminal.

Here are some examples of how to use the bg command:

  • To run a job in the background, you can use the bg command followed by the job identifier. For example:
refer to:‮al‬utturi.com
# Run job 123 in the background
bg 123
  • To list the jobs that are running in the background, you can use the jobs command. For example:
# List the jobs running in the background
jobs
  • To bring a background job to the foreground, you can use the fg command followed by the job identifier. For example:
# Bring job 123 to the foreground
fg 123
  • To kill a background job, you can use the kill command followed by the job identifier. For example:
# Kill job 123
kill 123

Overall, the bg command is a useful tool for running jobs in the background in a Unix or Linux system. It allows you to run long-running tasks or processes without tying up the terminal, and provides a number of options for managing background jobs.

Created Time:2017-10-29 22:08:59  Author:lautturi