8

This question is about executing /usr/bin/Xorg directly on Ubuntu 14.04.

And I know there exists Xdummy, but I couldn't make the dummy driver work properly with the nvidia GPU so it's not an option.

I copied the system-wide xorg.conf and /usr/lib/xorg/modules, and modified them a little bit. (Specified ModulePath in my xorg.conf too)

Running the following command as root works fine:

Xorg -noreset +extension GLX +extension RANDR +extension RENDER -logfile ./16.log -config ./xorg.conf :16

But if I do that as a non-root user (the log file permission is OK), this error occurs:

(EE) 
Fatal server error:
(EE) xf86OpenConsole: Cannot open virtual console 9 (Permission denied)
(EE) 
(EE) 
Please consult the The X.Org Foundation support 
     at http://wiki.x.org
 for help. 
(EE) Please also check the log file at "./16.log" for additional information.
(EE) 
(EE) Server terminated with error (1). Closing log file.

Could you please help me to run Xorg without sudo??

4
  • I don't think it's possible to run X as non-root; it needs to access lots of hardware and system stuff directly.
    – dirkt
    Oct 8 '16 at 18:15
  • 3
    set setuid bit on Xorg: chmod +s $(which Xorg)
    – Serge
    Oct 8 '16 at 20:06
  • @dirkt It's possible on recent systems but not with all drivers. See e.g. Ubuntu, Debian, Fedora, Gentoo, Arch, … Oct 8 '16 at 21:34
  • Thank you guys! It seems like your advice worked for me!
    – noname
    Oct 9 '16 at 9:40
6

To determine who is allowed to run X configure it with

dpkg-reconfigure x11-common

There are three options: root only, console users only, or anybody. The entry is located in /etc/X11/Xwrapper.config.


Since Debian 9 and Ubuntu 16.04 this file does not exist. After installing xserver-xorg-legacy, the file reappears and its content has to be changed from:

allowed_users=console

to:

allowed_users=anybody
needs_root_rights=yes

You also need to specify the virtual terminal to use when starting X, otherwise, errors may occur. For example:

Xorg :8 vt8
5

X needs access to input devices (mouse and keyboard) and to the monitor and graphics card for output.

To achieve this for non-root X, you can change the group of Xorg from root to input, set the setgit bit, and add your user to group video:

chown root:input /usr/lib/xorg/Xorg
chmod g+s /usr/lib/xorg/Xorg
adduser YOURUSERNAME video

(Instead you could add your user to both video and input, but that is discouraged. A user in group input can spy on inputs of other users. E.g. a GUI in X could probably spy on root password typed into console/tty.)

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.