Is there a way to start a program from a terminal, that is not a "child" of the window manager (p.e. XFCE), into a window manager?

The executed program has to be detached form the terminal (and my current connection to the server), so that it keeps alive after the terminal session is closed.

An example would be, connecting via ssh (without x-forward or similar) to a server, starting a browser, closing the connection. Sitting in front of the server and using the recently opened browser, which is still running,. detached from my ssh session with a new "owner" the window manager.


The usual methods of detaching a process from the shell are:

  • run in background using &, then ask the shell to stop tracking it using disown:

    $ xterm &
    $ disown

    (or xterm & disown)

  • run in background using &, and use the nohup tool to prevent it from being killed:

    $ nohup xterm &
  • run in background using &, and use double-fork to prevent the shell from tracking it:

    $ (xterm &)
  • run in background using setsid:

    $ setsid xterm

(Try (setsid xterm &) if some options don't work.)

  • Disown doesn't work as i estimated. The xterm of your example opens on my desktop (i needed to start a x-server locally) and isn't displayed on the server (that's what i needed). Also: closing my ssh connection terminates the xterm. (I m aware of the reasons why this is happening) – inselberg Jul 25 '14 at 4:31

xterm -e "bash -c \"./script.sh; exec bash\"" &

where ./script.sh can be just a command.


Log into the machine running the X server with SSH and run:

DISPLAY=:0 xterm &

You should get an xterm on your X display, and it should stay open even when you close the SSH session.

X11 applications use the DISPLAY environment variable to find the X server; the typical value is :0, which means that X11 applications should connect to a local X server through the Unix domain socket /tmp/X11-unix/X0.

Applications launched from within an X session inherit a DISPLAY environment variable that points to the X server, but processes started outside an X session (such as an SSH login) won't have that variable. That's why you have to explicitly set it when launching an X11 application from an SSH login.

  • But i need a "xterm" on the servers XFCE, not locally. – inselberg Jul 26 '14 at 8:45
  • Right, so SSH into the server and run the command. – Wyzard Jul 26 '14 at 13:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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