33

So when i try to use the Xorg command as a normal user, this is the error that it gives me :

/usr/lib/xorg/Xorg.wrap: Only console users are allowed to run the X server

but i don't understand, what are the "console users"? and when i switch to root it gives me another error :

_XSERVTransSocketUNIXCreateListener: ...SocketCreateListener() failed
_XSERVTransMakeAllCOTSServerListeners: server already running
(EE) 
Fatal server error:
(EE) Cannot establish any listening sockets - Make sure an X server isn't already running(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 "/var/log/Xorg.0.log" for additional information.
(EE) 
(EE) Server terminated with error (1). Closing log file.

So what is going on and what are the reason for each of these errors?

UPDATE: and the output of the command netstat -ln | grep -E '[.]X|:6[0-9][0-9][0-9] is :

unix  2      [ ACC ]     STREAM     LISTENING     18044    @/tmp/.X11-unix/X0
unix  2      [ ACC ]     STREAM     LISTENING     47610    @/tmp/.X11-unix/X1
unix  2      [ ACC ]     STREAM     LISTENING     18045    /tmp/.X11-unix/X0
unix  2      [ ACC ]     STREAM     LISTENING     47611    /tmp/.X11-unix/X1
12
  • @sourcejedi can you give me a link or resource that explains this console user? i googled console users in linux but there was nothing!
    – John P
    Oct 30, 2018 at 20:35
  • please edit your question to note the version of Debian. The question I linked claimed that Xwrapper is not used anymore in Debian 9. (I think the "console users" error comes from Xwrapper, although it's possible your message comes from new-style Xorg that you run directly and which gains access using systemd-logind.
    – sourcejedi
    Oct 30, 2018 at 20:36
  • @sourcejedi I'm actually using Kali linux which is debian based, the kali version is 2018.4, also when i run it as root it won't give me that console user error anymore, but some new types of error : Fatal server error: (EE) Cannot establish any listening sockets - Make sure an X server isn't already running(EE)
    – John P
    Oct 30, 2018 at 20:45
  • 1
    @sourcejedi yes it changed from Xorg.0.log to Xorg.1.log, and i updated the question for the output of the command you mentioned
    – John P
    Oct 31, 2018 at 13:37
  • 1
    @dirkt how can root not have the privilege for that? i thought root has all the privileges
    – John P
    Oct 31, 2018 at 14:20

5 Answers 5

45

If you are sure about the security implications (anyone can start the X-Server with root rights, which, since it has privileged hardware access and accesses a lot of files can open up a big security hole) and care only for functionality, not for security, for this part of your problem:

So when i try to use the Xorg command as a normal user, this is the error that it gives me :

/usr/lib/xorg/Xorg.wrap: Only console users are allowed to run the X server

the following can help:

You can add to

/etc/X11/Xwrapper.config

the line

allowed_users = anybody

Explanation from man Xorg.wrap:

CONFIG FILE
[...]
allowed_users = rootonly|console|anybody

Specify which users may start the X server through the wrapper. Use rootonly to only allow root, use console to only allow users logged into a physical console, and use anybody to allow anybody. The default is console.

5
  • Don't do this... When X is already running and if another user (whoever) tries to call it again everything will crash.
    – 71GA
    Apr 16, 2021 at 10:34
  • @71GA: If the machine is used just by a single user, without remote login, like a personal laptop, then this scenario should not apply. If other users who you not really trust can access the machine, then they should not be allowed to run X with root rights anyway. Apr 17, 2021 at 22:26
  • Two processes can call X server on the same machine... It can apply. I tried this and it crashed my computer.
    – 71GA
    Apr 19, 2021 at 7:24
  • @71GA: When two processes want to start an X server on the same virtual console andwith the same display ($DISPLAY-variable), then something is wrong anyways. And yes, as a user of a machine you can and are allowed to crash the stuff you have the right to run and maintain. Mar 31 at 16:33
  • Worked fine for me. Apr 11 at 23:34
13
/usr/lib/xorg/Xorg.wrap: Only console users are allowed to run the X server

but i don't understand, what are the "console users"?

It means you need to be running from the Linux text console, it actually does not matter what user you are. (Except that root is always allowed). Confusing :).

There are two different examples of switching to the Linux text console (and back) here, depending on exactly how your system is configured:

Switch to a text console in Fedora

The details can vary, as to which numbered consoles (Ctrl+Alt+F1, Ctrl+Alt+F2, etc) allow a text login, and which ones are used for graphical sessions (or not used at all).


I keep getting the message: "Cannot establish any listening sockets..."

You get an error message like:

_XSERVTransSocketINETCreateListener: ...SocketCreateListener() failed
_XSERVTransMakeAllCOTSServerListeners: server already running
Fatal server error:
Cannot establish any listening sockets - Make sure an X server isn't already running

This problem is very similar to the previous one. You will get this message possibly because the lock file was removed somehow or some other program which doesn't create a lock file is already listening on this port. You can check this by doing a netstat -ln. Xservers usually listen at tcp port 6000+, therefore if you have started your Xserver with the command line option :1 it will be listening on port 6001. Please check the article above for further information.

As this says, there is more information about what :0, :1, :2 mean, immediately above the quoted section:

https://www.x.org/wiki/FAQErrorMessages/#index5h2

(Note that you are using a more modern X server config, which does not listen on any TCP ports. This is why your error happens in _XSERVTransSocketUNIXCreateListener, instead of _XSERVTransSocketInetCreateListener. But the principle is exactly the same).

When i tried Xorg :2 in my virtual machine with Kali, the screen went black, why did this happen?

A-ha, yes :-D. Xorg is a graphics server. If you want to show some graphics on it, you need to run some client programs.

Xorg also starts up with an empty cursor nowadays. It's deliberately featureless, to avoid flashes / inconsistencies when starting your graphical stuff. This has changed - when I first used Xorg, the default background and cursor were quite obtrusive. If you want to see what that looked like, you can pass the -retro option :-).

Traditionally - and I think this is the behaviour with Xwrapper - Xorg would grab an unused console and switch to it. In this case you can switch back to your previous console (see above). Of course you can switch back again to the Xorg server, once you find which number console it grabbed :-).

If you are running a virtual machine on Linux, your VM will provide some method to inject the key combination Ctrl+Alt+F1 or whatever, because pressing that key combination probably switches consoles on your real machine.

I would tell you to compare startx -- :2, which (hopefully) launches some clients as well as an X server :-). However, the most popular modern GUIs now explicitly do not support multiple sessions. So you must make sure to logout your existing GUI session, before you run startx. Otherwise, it might look like it works, but then go wrong in weird ways that you don't understand.

2
  • Thanks for the answer, one thing i forgot to mention is when i tried Xorg :2 in my virtual machine with Kali, the screen went black, why did this happen?
    – John P
    Oct 31, 2018 at 15:57
  • @JohnP edited. The answer is "because you started Xorg". However, this is unsettling and it was clear you weren't familiar with Xorg, so I think the answer probably does need to say something about why this is expected.
    – sourcejedi
    Oct 31, 2018 at 16:35
1

I was using the startx command to start DWM and I inserted it in my bashrc so that I won't have to type the startx command manually everytime I login that's when I started getting the 'only console users are allowed to use teh x server' error SO i removed the startx command from the bashrc that means i have to start the server manually but now I don't get the error anymore

1
  • 1
    You should not add it in the .bashrc. Commands in there are executed every time you open another terminal. Instead you should add it to the .bash_profile. Comands in here will be executed only at login.
    – 71GA
    Apr 16, 2021 at 10:24
0

To access the console as a normal user, when not logged into the console, you may also need to add root privileges to the config. Doing this for myself fixed the issue:

$ tail -2 /etc/X11/Xwrapper.config 
allowed_users=anybody
needs_root_rights=yes
0

This happen to me with a new install of CentOS 9. The problem turned out to be that the /etc/X11/Xresource file permissions had to be changed to include all groups, as root:

# chmod 775 /etc/X11/Xresource

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .