- How to Run an Application in Linux
- How To Run an Application in Linux
- How To Run a Program Using Terminal in Linux
- How To Run Program Using Run Command In Linux
- How To Run Program using Application Menu
- How To run Program using Application Launcher Search
- How To Run Program Using Keyboard Shortcuts in Linux
- Conclusion
- About the author
- Syeda Wardah Batool
- How to Run Linux Commands in Background and Detach in Terminal
- Run Linux Command or Process in Background
- Keep Linux Process Running After Logout
- Detach a Linux Process From Terminal
- Related Posts
- 10 thoughts on “How to Run Linux Commands in Background and Detach in Terminal”
- How do you open a command line?
How to Run an Application in Linux
Launching an application using an operating system is the basic task that anyone can perform. The working process of the Linux operating system is totally different from other operating systems like Windows OS or macOS. If you’re a Linux beginner, and want to know different ways to launch or run an application, this tutorial will show you all easy and possible ways.
How To Run an Application in Linux
Linux distribution always has several solutions to perform one operation. You will find multiple choices and can select any of them.
To run an application/program in Linux distributions can be done using command-line and GUI as well. These are the tricks we will cover in this tutorial to run a program:
(I am using Linux Mint 21 to explain these methods)
How To Run a Program Using Terminal in Linux
Most beginners might think that launching an application through GUI is easy. But when you use the command-line, it looks even easier.
To open the application through command-line, open the terminal and type the program name:
How To Run Program Using Run Command In Linux
The “run command” is an alternative way to get apps quickly without using a terminal. All distributions of Linux have run commands as a built-in tool. It is quite simple, when you press “alt+f2”, a dialogue box will appear instantly with a pop-up “Enter a Command”:
Enter a program name in the dialogue box and hit enter:
How To Run Program using Application Menu
Like Windows, an application launcher is the most common way to run programs. Application launcher has a list of several icons that you can run on time. As we are working on Linux Mint, you will see the application launcher at the bottom left corner of the screen. To run the application, simply navigate to that application icon and click it:
How To run Program using Application Launcher Search
Application menu is yet another easiest way to run programs on screen. What you need to do is open the application menu by clicking its icon located at the top left corner of the screen:
It will redirect you to the Software Manager, navigate towards the search bar and type the program name with correct spelling and select it to open:
How To Run Program Using Keyboard Shortcuts in Linux
If you’re a keyboard user and don’t prefer to use a mouse, then this trick will help you. Keyboard shortcuts allow the user to run programs without using a mouse. It would be done when paying attention to the few steps we have mentioned below:
Open the application menu, type keyboard in the search bar and hit Enter:
Move to the “Shortcuts” tab, select “Launchers” from the left corner and you will get “Custom Shortcuts” there, hit it and add any shortcut you want.
Conclusion
The Linux operating system provides multiple ways to the beginner. It helps them to learn each way and select their favorite one to perform the task. Similarly, this article has shown multiple tricks to run or launch a program in Linux. We have mentioned 6 easiest approaches to run or launch a program on a Linux system.
About the author
Syeda Wardah Batool
I am a Software Engineer Graduate and Self Motivated Linux writer. I also love to read latest Linux books. Moreover, in my free time, i love to read books on Personal development.
How to Run Linux Commands in Background and Detach in Terminal
In this guide, we shall bring to light a simple yet important concept in process handling in a Linux system, which is how to completely detach a process from its controlling terminal.
When a Linux process is associated with a terminal, two problems might occur:
- Your controlling terminal is filled with so much output data and error/diagnostic messages.
- In the event that the terminal is closed, the process together with its child processes will be terminated.
To deal with these two issues, you need to totally detach a process from a controlling terminal. Before we actually move to solve the problem, let us briefly cover how to run processes in the background in Linux.
Run Linux Command or Process in Background
If a process is already in execution, such as the tar command example below, simply press Ctrl+Z to stop it then enter the command bg to continue with its execution in the background as a job.
You can view all your background jobs by typing jobs . However, its stdin, stdout, and stderr are still joined to the terminal.
$ tar -czf home.tar.gz . $ bg $ jobs
You can as well run a Linux process in the background using the ampersand, & sign.
$ tar -czf home.tar.gz . & $ jobs
Take a look at the example below, although the tar command was started as a background job, an error message was still sent to the terminal meaning the process is still connected to the controlling terminal.
$ tar -czf home.tar.gz . & $ jobs tar: ./.config/etcher: Cannot open: Permission denied
Keep Linux Process Running After Logout
We will use the disown command, which is used after the process has been executed and put in the background, its work is to remove a shell job from the shell’s active list jobs, therefore you will not use fg , bg commands on that particular job anymore.
In addition, when you close the controlling terminal or log out, the job will not hang or send a SIGHUP to any child jobs.
Let’s take a look at the below example of using the diswon bash built-in function.
$ sudo rsync Templates/* /var/www/html/files/ & $ jobs $ disown -h %1 $ jobs
You can also use the nohup command, which also enables a process to continue running in the background when a user exits a shell.
$ nohup tar -czf iso.tar.gz Templates/* & $ jobs
You might also like:
Detach a Linux Process From Terminal
Therefore, to completely detach a process from a controlling terminal, use the command format below, this is more effective for graphical user interface (GUI) applications such as Firefox:
In Linux, /dev/null is a special device file that writes off (gets rid of) all data written to it, in the command above, input is read from, and output is sent to /dev/null.
You might also like:
As a concluding remark, provided a process is connected to a controlling terminal, as a user, you will see several output lines of the process data as well as error messages on your terminal. Again, when you close the controlling terminal, your process and child processes will be terminated.
Importantly, for any questions or remarks on the subject, reach us by using the comment form below.
Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge.
Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.
Related Posts
10 thoughts on “How to Run Linux Commands in Background and Detach in Terminal”
Hey, Thanks for this little Linux tip, useful for me to make my Linux commands run in the background… Reply
Without the “disown” you’ll get the following output in the source terminal after the given program is closed: “[1]+ Done firefox /dev/null” This only happens the next time something is put out to the terminal’s output stream. So, the next time command runs that writes to the output stream. To test this, run it without “disown”, close firefox, and then run “ls”. Reply
I see this is an old post but I think my question is sort of in the ballpark. what I would like to do is open the console of the process that was started with systemd with a no GUI flag. what this pertains to the Minecraft server. so I made a systemd service file and the execution command is “java -jar server.jar nogui” now once the system is up and running, I would like to open the GUI or console of the Minecraft server to issue commands without having to open a Minecraft launcher like you would play the game. I know I have done something like this in the past on other platforms but I just don’t know enough about Minecraft/java to make this happen. I am using ubuntu 18.04 and the current version of the Minecraft is 1.15.2 Reply
How to see the jobs running in the previous session? I have submitted jobs in nohup and logged out. After logging again if i wanna see the jobs and if I wanna kill, how to do so Reply
@Bala You can run this command:
ps -fu username #replace username with your real username
OR
ps -x Reply
How do you open a command line?
You can launch your terminal by pressing Ctrl + Alt + T or search from dash by pressing Meta / Super / Windows button and type terminal.
If you’re using Gnome, Terminal is probably under Accessories in your Application menu, or you can also try Alt F2 to bring up a launcher widget into which you can type «t-e-r-m-i. » to see all the terminal options.
Worth adding that Terminal is probably under Accessories in your Application menu (it is for me anyhow, but I gave Unity the boot. Maybe Unity doesn’t have an Application menu). You can also try alt f2 for a launcher widget where you can start to type «t-e-r-m-i. » and get a list of terminal applications available to you.
Since I’m not using gnome now, I cannot update my answer. If you have gnome, feel free to edit my answer by adding screenshot for both gnome and gnome classic.
Press Ctrl Alt T on the keyboard. If you prefer, there should be something called Terminal in your programs menu. You can search for it by pressing «Windows» key and typing «terminal». Remember, commands in Linux are case sensitive (so upper- or lower-case letters matter).
Command line can be accessed in couple of ways.
One is by using terminal emulator . The default terminal emulator for Ubuntu ( with default Unity interface ) is gnome-terminal. It can be accessed by either pressing Ctrl Alt T or by pressing the Ubuntu icon on the launcher and typing in the word «Terminal» or «gnome-terminal»
As you can see in the image, I’ve multiple terminal apps available, and indeed one can install more than one terminal emulator.
Another way to access command line is through the virtual console, called TTY. There are 6 virtual consoles available. Number of each console corresponds to the number of Fx key, where x is the number. For instance, to access TTY1, press Ctrl Alt F1 . To return to graphical environment , press Alt F7 , or repeatedly press Alt Arrow Left/Right until you exit.
There are other, rather hackish ways to access command line , but for the 99% of the day-to-day tasks terminal emulator and tty are sufficient.