Re: X windows not working for root user

Jens.Toerring_at_physik.fu-berlin.de
Date: 05/19/04


Date: 19 May 2004 08:19:50 GMT

user@domain.invalid wrote:
> I have installed a new debian KDE distribution.
> I log in as a user and everything works fine.
> I then open a shell and use 'su' to change to root.
> Then as root I can't run any program that want to use
> a X window.
> Below is what is display on the shell.
> --- snip ---
> Xlib: connection to ":0.0" refused by server
> Xlib: Invalid MIT-MAGIC-COOKIE-1 key

> (gedit:28819): Gtk-WARNING **: cannot open display
> --- snip ---
> Any ideas what might be wrong?

Nothing is wrong. But normally only the logged in to the graphical
inter face user has access to the display. That's for security rea-
sons, if every user could get at it (and Linux is a real multi-user
system, so there could be dozens of other users logged in at the
same time, e.g. via a terminal) then they all would have a chance
to see what you're doing, including e.g. logging each of your key-
strokes. And that's something that is made impossible by default.
But there's a simple solutions: put something like

alias r='su - -c "xauth merge $HOME/.Xauthority;export DISPLAY=:0.0;xterm"'

into your .alias file (assuming you're using bash) and use that new
'r' command when you want to become root with access to the graphical
stuff.

Another, less secure method is to allow everyone on the local
machine access to the graphical interface by

> xhost +localhost

and then you have to set the DISPLAY variable after 'su' with

# export DISPLAY=:0.0
                                   Regards, Jens

-- 
  \   Jens Thoms Toerring  ___  Jens.Toerring@physik.fu-berlin.de
   \__________________________  http://www.toerring.de


Relevant Pages

  • Re: X windows not working for root user
    ... > I then open a shell and use 'su' to change to root. ... > Below is what is display on the shell. ... user's .Xauthority file. ...
    (comp.os.linux.development.apps)
  • X windows not working for root user
    ... I have installed a new debian KDE distribution. ... I then open a shell and use 'su' to change to root. ... Xlib: connection to ":0.0" refused by server ...
    (comp.os.linux.development.apps)
  • Re: Professional Display Shooters Tricks of the Trade
    ... that's one of the functions that the buckets of water provided. ... What I described in my post on display shooting is the accumulated ... shells with the timing fuse on top of the shell, ... with your flare and throw into the mortar. ...
    (rec.pyrotechnics)
  • Re: hi all..
    ... and someone gets access your shell account, ... Only root can install an su binary. ... Of course, if I have sudo ...
    (Fedora)
  • Re: Electric matches and firing boxes...
    ... Typically you match one redundant ematch at the start of your finale ... In the world that I travel in, which is classic Italian style fireworks ... Swansea decided that their $5,000+ display would go on come rain ... display shell from the box. ...
    (rec.pyrotechnics)