This is also another Linux command I tend to forget. I usually need to re-search how to run Linux commands in the background. This happens when I stop using the command line for a while. This time I’m going to write a brief Linux tutorial about this. First I need have brew a good cup of coffee from Nicaragua while wearing my Moka pot beanie at home.
I’m sure there are more ways to run Linux commands in the background, but I’m adding the four ways to accomplish it for now.
1. Add the ‘&’ ampersand after the command
For example, if you want to launch VSCode or other app from the command line. You can also run any scripts:
2. Use the bg command
This one is simple to use, but I didn’t understand how it worked. For example:
Then press the keys Control+Z. This suspends the running process. Then, type:
You will see something like:
+ some_command &
Then, use the jobs command to see the running process/commands running in the background.
3. Screen Command
This one I find it very easy to use. In your Terminal type:
You will be presented with something like this:
Type your command as usual. Then press control+a followed by a ‘d’. This will detach it from the screen session and place it in the background.
You can type screen -r to re-attached the session.
4. nohup command
The nohup command you can run a script/command and you can exit your Terminal and the process will remain.
nohup your_command &
There are many other ways to run Linux commands in the background. The above are only some. I’m still learning. Contact me if you have any questions or want to collaborate. Thanks.
My shop. I make my own designs.