When I launched GUI programs from a terminal window (with '&' at the end), how can I close the terminal without also closing the GUI programs?

  • Not meant to be a competing answer to Paul w. Maud'dib's answer, which looks like a straightforward and simple solution, but a supplemental idea: Run a terminal multiplexer (tmux or screen). When you kill the parent bash, the terminal multiplexer and its children will live on. The terminal multiplexers are great: quick keyboard shortcuts to create a new session, detach protection (very useful for remote shells!), text-mode copy and paste capabilities (besides whatever a GUI might offer), quick window splitting (into multiple shells), etc. – TOOGAM Dec 15 '17 at 14:16

You can use disown to omit the program from getting sent a hang-up call from it's starting terminal. This way the GUI program stays open when the terminal is closed.

  • Ah, it seems like disown is a command built into bash (so bash's man page has the details on this command). Do you happen to know, is the effect of having sub-programs close a trait rather unique to bash, or does bash just provide a solution to an issue that tends to be more widespread (affecting other Unix shells too)? P.S., I see your answer was just accepted (while I typed this comment). Congrats. – TOOGAM Dec 15 '17 at 14:19
  • 1
    I just looked up the documentation for zsh (which i use on another machine) and it also features the ´disown´ command. After checking the manpage of ksh, it also seems to feature the ´disown´ command. – Paul w. Muad'dib Dec 16 '17 at 18:48

Use nohup to run the program, it will "run a command immune to hangups, with output to a non-tty"

Just prefix the command with nohup, as in

nohup kdiff3

The & is even optional, and it's not dependent on bash.


Your desktop shell may provide a CLI utility to start a GUI program as if it were started from the desktop shell (I assume the utility actually asks the shell parent process to start that app). The command returns immediately, while the started app opens. You can close the terminal without killing the started application.


For the KDE/Plasma shell the utility is kstart <name_of_executable>:

kstart dolphin /var/log

GTK-based shells

You can use gtk-launch <base_name_of_desktop_file>:

gtk-launch firefox 

(assuming your have a firefox.desktop).

  • Interesting - but then I'd have to remember a different method per desktop. (I am using Cinnamon and Xfce.) – Robert Pollak Dec 16 '17 at 19:21
  • Make a (different) script on each... – xenoid Dec 17 '17 at 0:04

I use byobu for this purpose.

  1. First run byobu
  2. Then, on a virtual tab of byobu, run your command
  3. Then, even if you close the terminal, since byobu process is alive, your command is also alive.
  4. To reach your command again, open a terminal, call byobu. It will restore all virtual tabs including the one which contains your command, too.

Your Answer

