Starting GUI program from Linux terminal prevents further usage

I would search for this, but I have no idea how to phrase it for the search engine..

Basically, when I start a gui program from a terminal window, that terminal cannot be further used until I quit the program. I've just started using dwm, and I don't want to have useless terminals littered around after starting up a few graphical programs.. Is there any way around this?


Everyone saying to use "&" is right. If you happen to forget, type ^Z (ctrl+Z) to suspend the program, then "bg" to tell the shell to run it in the background. That leaves the shell fully interactive just as if you had started the program with the "&".


I realize this is an old thread, but I remember finding a more elaborate solution than those listed here.

$ (gui_app &> /dev/null &)

"&> /dev/null" redirects both stdout and stderr to the null device. The last ampersand makes the process run in the background. The parentheses around the command will cause your "gui_app" to run in a subshell.

Doing this will detach the "gui_app" process from the console you execute this command from. So even if you close the window parent terminal emulator is running in, "gui_app" won't close. I ran this then looked at the process tree with "pstree" command and found an application started this way will become child process to "init".

For example,

$ gui_app &> /dev/null &

will run the application in the background, but it will become a child process of the console process and will terminate when you close the terminal. (Though exiting the terminal through bash by using the exit command or Ctrl-D will let bash clean up by handing off the background process to init.)

Alternatively, you can use "nohup", but that redirects output & error to a file by default. "disown" command (if available in shell) can detach process from terminal after you've started a background process:

$ gui_app &
$ disown

(BTW all of this applies to bash. I'm sure other shells have other methods/syntax for doing this.)

Similar superuser Q&A - maybe where I remember some of the answers from: ... start GUI linux programs from the command line, but separate from the command line?

Some reference: Disowning Processes (UNIX Power Tools)

If it's a simple call to a GUI application - without complicated options and such - it seems using a launcher like "gmrun" or dmenu (warning: loud audio) is also a good option. Bind it to a key combination. I don't use a launcher yet but have tried those two.

NOTE: CarlF in the comments reports GUI apps started via "gui_app &" method does not close when he exits from the parent terminal. I think that we were closing the terminal in different ways. I was closing the window the terminal emulator was running in. I think he may have been exiting the terminal emulator through the shell (exit command or Ctrl-D). I tested this and saw that exiting through bash does not stop GUI started as terminal's background process as CarlF says. It seems bash hands off background processes to init when it is given the chance to clean up. In fact, this must be the mechanism by which the background process started in a subshell gets handed off to init.


You need to start the application in the background like this:

# xeyes &

The & indicates that the application should launch in the background.