PDA

View Full Version : Ubuntu X applications as root


geek.de.nz
23rd June 2006, 09:21
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

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.

chatmoa
23rd June 2006, 14:52
gsudo gvim on ubuntu
kdesu gvim on kubuntu

@+ :)

geek.de.nz
24th June 2006, 04:36
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

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):

xhost +



Hope that helps someone who has the same problem.