9

I've heard that there is a way launching programs with graphical interface without display manager - straight from terminal. Is this for real and if so, how can I do that?

  • Do you need to interact with the GUI? – Daniel B Apr 21 '15 at 9:47
  • @DanielB yeah, probably – Ben Apr 21 '15 at 9:47
  • 1
    You can run them with no display manager, but you do need a running X session. What distribution are you using? Do you have an X server installed? Can you run xinit or startx? – terdon Apr 21 '15 at 10:00
  • @terdon yeah, i'm currently running lmint, but the question is more for general knowledge (not distro targeted). – Ben Apr 21 '15 at 10:02
5

You can run them with no display manager, but you do need a running X session. The details will depend on your distribution but you should be able to get a minimal X session with a single terminal by running

xinit

I haven't done this in years but, last time I did, that would give something like this:

enter image description here

Once there, you can run a GUI program normally, preferably by launching it in the background (with &) so you don't loose access to your only terminal.

  • 2
    It might be worth mentioning that "running them normally" will most likely involve backgrounding the process, so you'd most likely want to use xterm & to get an additional terminal, not just xterm. Etc. – a CVn Apr 21 '15 at 18:29
6

Here is the basics for running an GUI app headless, with a way (vnc) to connect to it. Works on RHEL7 and Centos 7, with family. And ripped out of my own Docker-image that I use for Crashplan located at https://github.com/xeor/dockerfiles/tree/master/crashplan/ (see Dockerfile for setup, and init/setup for startup.

# Needed environment variables
export DISPLAY=:99.0
export SCREEN_WIDTH=1200
export SCREEN_HEIGHT=960
export SCREEN_DEPTH=24
export GEOMETRY="${SCREEN_WIDTH}x${SCREEN_HEIGHT}x${SCREEN_DEPTH}"

# Needed packages
yum install -y xorg-x11-server-Xvfb x11vnc gtk2 xorg-x11-fonts-*

# Set a password (if variable vncpass is sat, else its `secret`)
mkdir -p ~/.vnc && x11vnc -storepasswd ${vncpass:-secret} ~/.vnc/passwd

# Start up the fake display and run the application you want (the `java ...` part)
xvfb-run --server-args="$DISPLAY -screen 0 $GEOMETRY -ac +extension RANDR" java .... > log/ui_output.log 2> log/ui_error.log &

# Wait for the app to start, or else, the vnc server will die before starting
sleep 5

# vnc itself
x11vnc -forever -usepw -shared -rfbport 5900 -display $DISPLAY

You should now be able to connect to the server:5900 and see the application.

3

Yes. Just do the same things a display manager does. Aside from the graphical login screen (which you don't need in this case), the display manager just does two things:

  1. First it starts an X11 "display server", such as Xorg,
  2. then starts "clients" which tell Xorg what & where to draw.

You can use tools like startx to start X11 the same way from a console login; it will launch Xorg followed by the clients listed in your ~/.xinitrc file.

For example, the .xinitrc file could have startkde or gnome-session, or it could list the individual components (the window manager, a panel/taskbar, a desktop...)

(Note that there are some differences between xinit and startx – usually you should use the latter, since some distros have a few important pieces of configuration that plain xinit will ignore, namely the xserverrc script.)

With Wayland, the desktop & panels are an integrated part of the "compositor", so the entire interface starts in a single step without additional tools. For example, you can run weston or start GNOME using gnome-session --session=gnome-wayland.

1

You can launch X applications using ssh X forwarding (ssh -X; may need to be enabled in server config as well), provided you have a local X display.

The application will launch and display locally, while running on a headless system. You will need to have X installed on the headless system in order to have the right libraries, and this may not work with more modern GNOME applications.

You can also use $DISPLAY to launch apps on an attached X display even if your shell is a remote one (ssh or console). If you're root and the person logged in on the X display isn't, you can override the xauth security and pop up a window on their display anyway. This also works if you have two different X display servers on different monitors.

Another poster mentions VNC; I've also used NX for this purpose, and I prefer it.

  • Answer is unrelated, but usefull – Ben Apr 21 '15 at 11:42

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.