Ubuntu – How to run /usr/bin/Xorg without sudo

not-root-useropenglUbuntuxorg

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??

Best Answer

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
Related Question