In reality, when you run a command in the terminal, you have to wait until the command finishes before you can enter another one. This is called running the command in the foreground or foreground process. When a process runs in the foreground, it occupies your shell, and you can interact with it using the input devices.
So While working on your system, there are times you want specific processes to run in the background, i.e., they will continue to work. Still, they will not interpret the working of any other processes running in the foreground.
Here at LinuxAPT, we shall look into different ways of sending the processes to the background in Ubuntu Linux.
Here, you will see what happens to your terminal once you launch a program through it.
We will launch the Firefox browser with the help of the following terminal command:
$ firefox
Once the Firefox browser launches, you will lose control of the terminal.
Now, if you want to run any other command on the terminal, you will not be able to do that because you no longer have control of the terminal.
You will be able to execute a terminal command only if you close the Firefox browser or send it to the background.
For sending any process to the background in Linux, you need to launch that process followed by the ampersand operator, and running the following command:
$ firefox &
Running this command will display a job ID on the terminal.
This time, the Firefox browser will launch on your system. However, you will still have control of the terminal in your hands, which means that you will still be able to execute other commands while the Firefox process will be running in the background.
Here, we will launch the Firefox browser in the same manner as we did above in the first method. Now, you will see the Firefox browser.
Then, you need to press the Ctrl+ Z key combination to get control of the terminal back while the Firefox process will still be running.
Next, execute the following command to push the Firefox process to the background:
$ bg
If you ever want to view the processes running in the background in Linux, then you simply need to run the following command:
$ jobs
This will display the background processes running on the Linux system.
This article covers the ways of sending a process to the background in Ubuntu Linux system. In fact, a background process is a process/command that is started from a terminal and runs in the background, without interaction from the user.