12

Possible Duplicate:
How to clean launch a GUI app via the Terminal (so it doesn't wait for termination)?

I start a program from terminal with the following command:

<program name> &

But when I close the terminal the program will close too. How to escape the program closing?

2
  • I can write firefox in terminal and then close terminal without a problem
    – AWE
    Aug 19, 2014 at 19:28
  • This is not the same question as the one marked as a duplicate. In the question here, the OP applies the knowledge from the other question (using the &) and then asks the new question how to close the terminal without killing the application that had been started successfully.
    – ernstkl
    Mar 21, 2019 at 13:40

2 Answers 2

15

You can close the terminal by pressing Ctrl-D at the prompt instead of using the window controls. This will do what you want.

1
  • Good answer. I would have suggested the same, if I had known about it. :-) ... Looking at the tree view of htop, it seems that this somehow removes the terminal from the parent node, and "promotes" the program to the parent's level. With gedit, its parent became "init", the top (or root) level of the tree. Thanks, it's nice to know this trick; I always used alt-F2 to run programs instead, but this might be more convenient. Jul 14, 2012 at 19:45
5

One solution is to use screen and detach from it:

sudo apt-get install screen    
screen
<program name> &
ctrl-a ctrl-d (this detaches the screen session)

This is useful especially when starting programs on remote servers. You can then run screen -R to reattach. See this howto.

Not the answer you're looking for? Browse other questions tagged or ask your own question.