Skip to content

Fg command on Linux (processes in the foreground)

The fg command on Linux does the exact opposite of the bg command, placing the task or background process in the foreground and connected to a terminal.

It also accepts that a job number is passed as a parameter.

In this example again the find command is placed in the background with Ctrl-Z and it gains the number of Job1:

$ find/-iname a* 2>/dev/null ^Z [1] + Stopped find/-iname a* 2> /dev/null

To view programs running in the background, the jobs command can be executed:

$ jobs [1] + Stopped find/-iname a* 2> /dev/null

To return the Job to the foreground and connected to the terminal, simply run fg. In this example, the Job number was passed as a parameter:

$ fg 1 find/-iname a* 2> /dev/null

Learn much more about Linux in our online course. You can register here. If you already have an account, or want to create one, just log in or create your user here.

Did you like it?

Share