3

How to determine, as root, which user owns X display :0? (on a Fedora 18 system with defaults)

  • 2
    Is your question actually is "who opened a session on display :0?" ? If this is the case, you should consider edit your question. Here, I understand the question as "who launched the process that created the display :0?". – lgeorget May 4 '13 at 3:11
  • And if the question is "which user is is connected to display :0", there is no good answer: Multiple user can be connected to :0, and, with networking enabled on the X server, even users that don't exist on the local machine. Yes, today mostly a single user logs in to X, but that isn't how the architecture works. – dirkt Jun 15 at 13:48
1

ps -ef|grep X will give you the info.

For example, on my computer:

user001  2721  2705  0 02:35 tty1     00:00:00 xinit /home/user001/.xinitrc -- /etc/X11/xinit/xserverrc :0 -auth /home/user001/.serverauth.2705
root      2722  2721 13 02:35 tty7     00:10:10 /usr/bin/X -nolisten tcp :0 -auth /home/user001/.serverauth.2705
user001  3475  3462  0 03:51 pts/0    00:00:00 grep X

Here, we can see that user001 launched xinit and uses the display :0. However, root is the owner of the X process.

On most installations, users don't use the xinit command (or startx which internally calls xinit). The X server is launched by root during the bootup process. In that case, root is the "owner" of the display.

  • no xinit shows up on my system, fedora 18 with defaults – necromancer May 4 '13 at 2:41
  • Ok, but you see a X process owned by root? That means that the X server is launched and owned by root. So, you have your answer. I'll edit my answer to deal with that case. – lgeorget May 4 '13 at 3:05
  • hmm.. yes, but i did not login as root on the graphical user and the display is not owned by root. i think the "-auth /home/user0001/..." line might help though – necromancer May 4 '13 at 4:32
  • 1
    If your question is "how to know who is logged in", try the w command. And please reformulate your question, it's a bit ambiguous ;-). – lgeorget May 4 '13 at 12:09
-1

This is the exact command:

ps ho user $(pgrep X)

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.