Command Line

Don’t Let Applications Close When The Terminal Is Closed

You may have started an application from the terminal and noticed that those applications close when the terminal is closed. This article will help you stop that behavior. This should be a pretty basic and speedy article.

Let’s explain what I mean with a demonstration. First, open your terminal by pressing CTRL + ALT + T. Now, enter the following:

pcmanfm-qt

Change the ‘pcmanfm-qt’ to the file manager you use, like ‘nemo’, ‘spacefm‘, or whatever it is you use to manage files in a graphical way. Any one will do. 

Now, close the terminal that you used to open your file manager or application. When you do so, you’ll see that applications close when the terminal is closed. Well, it doesn’t have to be that way. 

Enter ‘nohup‘, a lovely tool that will let you open applications in the terminal and then make sure that those applications don’t close when the terminal is closed. The ‘nohup’ application should be installed by default on any major distro and the man page describes it like:

nohup – run a command immune to hangups, with output to a non-tty

If you check the man page, you’ll see that it has pretty much no useful flags other than help and version. So, straight away you’ll see that it’s a pretty easy application to work with.

And, with that ease in mind, I’m just gonna go straight into telling you how to use it.

Applications Close When The Terminal Is Closed:

Seeing as you already opened the terminal, let’s not mess about and just show you some uses of ‘nohup’. Let’s say you use ‘nemo’ as your file manager:

nohup nemo ~/Downloads

Now close the terminal. See? When you use ‘nohup’ you’ll not have applications close when the terminal is closed.

You may see the command used with an ampersand (“&”) symbol at various tutorial sites. What that does is it runs things in the background. This means it should immediately return to the command prompt after the application has opened. This only works if you’re using bash, by the way. If you use it, it looks something like this:

nohup nemo ~/Documents &

Anyhow, after you’ve used ‘nohup’ to open an application without the ampersand, you can also just press CTRL + C and disconnect the running application from the terminal while returning you to the command prompt. Later, when you close the terminal, you’ll find see that no longer do those applications close when the terminal is closed.

That’s about it, really. I don’t see any reason to stretch this article out by adding fluff. You’re welcome!

Closure:

There ya have it. Another article. This one will help you change the behavior, if you don’t want to have applications close when the terminal is closed. 

Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your own site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

KGIII

Retired mathematician, residing in the mountains of Maine. I may be old and wise, but I am not infallible. Please point out any errors. And, as always, thanks again for reading.

View Comments

    • Yeah, it's a pretty neat trick for when you open stuff in the terminal and want them to remain open.

Recent Posts

Enable/Disable Your Network Interface

Today we'll cover one way to enable or disable your network interface in the Linux…

6 months ago

Check Your NIC Speed In The Terminal

Today's exercise is a nice and simple exercise where we check your NIC speed in…

6 months ago

Easily Monitor Your Wireless Connection

Have you ever wanted to easily monitor your wireless connection? Well, now you can learn…

6 months ago

Count The Files In A Directory

I think I've covered this before with the ls command but this time we'll count…

6 months ago

Get System Information With The ‘uname’ Command In Linux

Today we'll be learning about a basic Linux command that's known as 'uname' and it…

6 months ago

hardinfo Has Been Rebooted As hardinfo2

If you've used hardinfo in the past, it may interest you to know that hardinfo…

6 months ago