Cannot connect to X server :0.0 [Solved]

Discussion in general that pertains to Sabayon Linux - Must Pertain to Sabayon Linux

Moderator: Moderators

Cannot connect to X server :0.0 [Solved]

Postby cmost » Sun Oct 17, 2010 22:02

Fully up-to-date with Sabayon 5.4 (all the way from 5.0) and now, when I try to run a program as root from the terminal I get the following error:

Code: Select all
[email protected] ~ $ sudo kate
Password:
No protocol specified
No protocol specified
kate: cannot connect to X server :0.0
[email protected] ~ $


The same occurs if I su to root. On the other hand, if I use "kdesu kate" (for example) from the terminal, it opens a KDE authorization dialog and then after entering root's password I can run the specified program with root privileges. Sudo used to work fine. Any ideas here? This is more of an annoyance than a hindrance.
Last edited by cmost on Sun Sep 04, 2011 17:40, edited 1 time in total.
AMD Phenom II 64 X6 1090T Black Edition
8192 MB DDR2 RAM
nVidia GeForce GTX 660 w 2048 MB DDR5
Sabayon 2014.x 64 Bit KDE
"Better to remain silent and be thought a fool than to speak out and remove all doubt." -- Abraham Lincoln
cmost
Advanced Hen
 
Posts: 208
Joined: Wed Dec 13, 2006 22:25
Location: Cincinnati, OH

Re: Cannot connect to X server :0.0

Postby cmost » Thu Oct 21, 2010 23:56

*Bump*

Anyone?
AMD Phenom II 64 X6 1090T Black Edition
8192 MB DDR2 RAM
nVidia GeForce GTX 660 w 2048 MB DDR5
Sabayon 2014.x 64 Bit KDE
"Better to remain silent and be thought a fool than to speak out and remove all doubt." -- Abraham Lincoln
cmost
Advanced Hen
 
Posts: 208
Joined: Wed Dec 13, 2006 22:25
Location: Cincinnati, OH

Re: Cannot connect to X server :0.0

Postby wolfden » Fri Oct 22, 2010 9:05

I'm not seeing a problem here

for KDE use kdesu foo

for gnome use gksu foo

The kdesu and gksu commands are for users in a GUI vs a terminal environment. If you do some googling you will see sudo vs kdesu
wolfden
Sharecropper
 
Posts: 9050
Joined: Sat Jan 14, 2006 0:55
Location: Midwest USA

Re: Cannot connect to X server :0.0

Postby cmost » Fri Oct 22, 2010 18:04

Hi Wolfden! I'm familiar with kdesu (KDE) or gtksu (Gnome) for running graphical tools as root versus sudo for doing the same in the terminal. The problem is that until recently, I used to be able to type sudo foo in a terminal and foo would open up as root on my desktop. Now, however, I receive the error I posted. It's true I can type kdesu foo and get the same result but I am wondering what is causing the error so that I might fix it and thus revert to the previous behavior that I prefer. Thanks.
AMD Phenom II 64 X6 1090T Black Edition
8192 MB DDR2 RAM
nVidia GeForce GTX 660 w 2048 MB DDR5
Sabayon 2014.x 64 Bit KDE
"Better to remain silent and be thought a fool than to speak out and remove all doubt." -- Abraham Lincoln
cmost
Advanced Hen
 
Posts: 208
Joined: Wed Dec 13, 2006 22:25
Location: Cincinnati, OH

Re: Cannot connect to X server :0.0

Postby wolfden » Fri Oct 22, 2010 19:23

Probably an environmental path, stuff is constantly changing upstream. I use kdesu and gksu without problems.
wolfden
Sharecropper
 
Posts: 9050
Joined: Sat Jan 14, 2006 0:55
Location: Midwest USA

Re: Cannot connect to X server :0.0

Postby cmost » Sun Sep 04, 2011 17:39

I realize I posted this problem awhile ago, and I've been happily using kdesu for awhile but I stumbled upon the solution to this problem today while researching something else and thought I would share the solution just in case anyone was interested. Here's how to get the sudo command to work with GUI applications again.

Open a terminal and issue the command:
Code: Select all
sudo nano /etc/sudoers


Scroll through the file and make sure the following two lines are present (where 'username' is YOUR username):
Code: Select all
root    ALL = (ALL) ALL
username    ALL = (ALL) ALL

# Run X applications through sudo
Defaults env_keep += "DISPLAY HOME"


CTRL+X to save the file

Now issuing
Code: Select all
sudo kate


should launch Kate as root.

:lol:
AMD Phenom II 64 X6 1090T Black Edition
8192 MB DDR2 RAM
nVidia GeForce GTX 660 w 2048 MB DDR5
Sabayon 2014.x 64 Bit KDE
"Better to remain silent and be thought a fool than to speak out and remove all doubt." -- Abraham Lincoln
cmost
Advanced Hen
 
Posts: 208
Joined: Wed Dec 13, 2006 22:25
Location: Cincinnati, OH


Return to Sabayon Linux General Discussion

Who is online

Users browsing this forum: No registered users and 2 guests

cron