My requirement is a little different from this one in that I would like to launch a window manager for each of two non-root users upon boot.

For testing, first I prepare the following lines in .xinitrc and/or .xsession in home directories of user2 and user3 like so:

exec icewm

Then I manually login to virtual console as user2 or user3 or open an xterm window and type this command:

xinit -- /usr/bin/Xvfb :3 -cc 4 -screen 0 1024x768x16

This does the job - icewm and Xvfb run behind the scene.

Now I want to automate the login and command xinit on boot. However none of the following approaches work:

Either manually type these two commands as root or place them in /etc/rc.local:

su -l user2 -c xinit -- /usr/bin/Xvfb :3 -cc 4 -screen 0 1024x768x16

No protocol specified
IceWM: Can't open display: :0. X must be running and $DISPLAY set.

start-stop-daemon --start -u user2 -g user2 -b --pidfile /tmp/pid --exec /usr/bin/xinit -- -- Xvfb :3
ps ax

[Xorg] <defunct>

Helps will be greatly appreciated!

[Edit after testing alex.d.'s approach]

File /home/user2/.xsession:

export DISPLAY=localhost:3
export XAUTHORITY=$HOME/.Xauthority
exec icewm

Issue this command as root:

su -l user2 -c /usr/bin/startx -- /usr/bin/Xvfb :3 &

I get this:

hostname: Name or service not known
xauth: (stdin):1:  bad display name "example.com:2" in "add" command

IceWM: Can't open display: localhost:3. X must be running and $DISPLAY set.
xinit: giving up
xinit: unable to connect to X server: Connection refused
xinit: server error
xauth: (argv):1:  bad display name "example.com:2" in "remove" command

Any idea? Please!


When starting X11 from rc.local, it's not started from inside a user session (consolekit or logind), so things are missing in the environment. Instead of a bare xinit, you should try to start X11 with startx which is intended to start a session.

  • I have just used startx instead and edited to show issues coming with that script. – Masa O May 27 '16 at 9:34
  • Why do you explicitely force values for $DISPLAY and $XAUTHORITY? In particular, DISPLAY=localhost:3 will work only if X is listenning on TCP sockets. It should be DISPLAY=:3 (or better: do not set it, startx will do it for you). And why force a value for XAUTHORITY? Especially if you do it in the .Xsession, it's to late and you lose the value set by startx. – alex.d. May 30 '16 at 9:22

This is my working approach.

file /etc/systemd/system/john.service:

Description=xinit - user "john"

ExecStart=/usr/bin/xinit openbox-session -- /usr/bin/Xvfb :1 -nolisten tcp
ExecStopPost=/usr/bin/killall -u john


file /home/john/.config/openbox/autostart:

wine my_program.exe

Thank you all for the helps!

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.