Skip to content
Search

Fg

lastmod 2021-10-18created 2015-12-091 edits

Run Background

To run a program in the background, put & at the end of the command.

cp test.tar test2.tar &

Foreground -> Background

You can move it to the background with Ctrl + Z.

$ vi test.rb

[1]+  Stopped                 vi test.rb

Since the job has been forcibly stopped, you can resume it with the bg command.

$ bg %1

Background -> Foreground

To bring a background job back, use the fg command.

$ fg %1

List of background

Use jobs to see the list of background jobs.

KILL

A background job is terminated as follows.

$ kill %1

Warning

Be careful not to leave out the % when using this command. If you leave it out, you will terminate init (PID 1) or kthread (PID 2), and you may have to reboot the computer.

See also

Favorite site