Tutorial to run Linux commands in the background
In this tutorial post, we will show you the method to run processes in the background. After this article, you will learn to Start a Linux Process or Command in Background.
How To Run Linux Commands In background
A background process runs in the background, without interaction from the user. It is started from a terminal. It is quite easy to run processes in the background or run Linux commands in the background. You just need to add ampersand (&) at the end of the command to run a Linux command in background.
your_command_execute &
For example:
tar -czf home.tar.gz &
If you want to see the list of commands running in the background then run the following command in the terminal:
jobs
How To Send Running Commands To Background
If you want to send a running command to the background in Linux then the process is quite easy as you can easily send these commands to the background by hitting the Ctrl + Z keys ) It stops the running process) and then using the bg command ( It takes the running commands to the background).
For example:
tar -czf home.tar.gz ^z bg
How To Bring A Process To Foreground In Linux
In the above commands, we learned the methods to send running commands to background in Linux. Now, we will see the steps to bring a process to foreground in Linux from the background. Run the following command to bring a process to the foreground in Linux
fg jobid
How Run Linux Process After Exiting Terminal
We will use nohup command to run the process even after exiting the terminal in Linux:
nohup tar -czf home.tar.gz Templates/* &
How To Make Terminal Free From Running Process
Run the following command to detach a Linux process from the controlling terminal.
firezilla </dev/null &>/dev/null &