Ubuntu X applications as root

Discussion in 'Desktop Operation' started by geek.de.nz, Jun 23, 2006.

  1. geek.de.nz

    geek.de.nz New Member

    I know, I can load X applications (X apps) as root with 'sudo xappname' and giving the password. But that takes too much time, every time I want to do something as root which involves the X server, I have to type the root password.

    But in other distros I was used to logging in as root in a shell (konsole) and typing 'xappname' and it would be displayed on the X server of the current user. But in Ubuntu I get
    Code:
    Xlib: connection to ":0.0" refused by server
    
    if I start gvim (my favorite editor) for example.

    I haven't found this issue on the web yet.

    Can anyone tell me, how to change the behoaviour of the X server of Ubuntu somehow, because root should really have every right shouldn't he? This is the only thing that keeps annoying me in Ubuntu.
     
  2. chatmoa

    chatmoa New Member

    gsudo gvim on ubuntu
    kdesu gvim on kubuntu

    @+ :)
     
  3. geek.de.nz

    geek.de.nz New Member

    xauth cookies

    That's what I know. It's not what I wanted to do (as I mentioned).

    Anyway, I figured it out. If you want to execute X apps as root (logged in as root in konsole or similar) while you are logged in with the user called user, you have two ways:

    1. (prefered because more secure)
    Log in as root and do
    Code:
    cp /home/user/.Xauthority ~/
    
    Then you can start an X app as root while user is logged in on the same X server.

    2. To allow any user to access the X server while logged in as user, use the xhost command (being user):
    Code:
    xhost +
    

    Hope that helps someone who has the same problem.
     

Share This Page