fbpx fg Command in Linux: Bring Processes to Foreground | Certificação Linux

fg Command in Linux: Bring Background Processes to Foreground

📅 12/08/2021 ⏱ 1 min ✍️ Uira Ribeiro
Linuxcommands
fg Command in Linux: Bring Background Processes to Foreground
Exam Pass App — mais de 7.000 questões LPI, offline, em 5 idiomas, disponível no Android e na App Store
Available on
Google Play
Available on
App Store

The fg command in Linux does exactly the opposite of the bg command, bringing the task or background process to the foreground and attached to a terminal.

It also accepts a job number as a parameter.

In this example the find command is again placed in the background with Ctrl-Z and it receives the Job number 1:

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

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

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

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

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

Learn much more about Linux in our online course. You can enroll 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

Uira Ribeiro

Prof. Uirá Ribeiro

Chair do Board do Linux Professional Institute

After years of watching professionals waste hours on simple tasks because they didn't know the right Linux tools, I decided to teach.
Today I'm the author of most of LPI's official Learning Materials and mentor to over 14,000 certified students.

See my full story →

That was just one piece. The course teaches the whole path — from your first command to exam day.

Certificação Linux — a plataforma líder em certificações Linux no Brasil
WhatsApp