You are not logged in.

#1 2015-07-17 20:26:55

navi_se
Member
Registered: 2015-07-06
Posts: 135

[SOLVED] Running GUI app with sudo

Hi, whenever I run an application using the sudo I get the following:

cannot open display

I've setup X following the wiki and the install is recent with kde 4.14.10. but I am thinking maybe some configuration is not proper, do you have any advice?

Previously I was running into a different error which named the display 0:0. I fixed by adding the follwing line to my

/etc/sudoers

file using

visudo

:

Defaults env_keep="DISPLAY"
Defaults env_keep="XAUTHORITY"
Defaults env_keep="HOME"

I have attempted different solutions mentioned on the web, to no avail.

    For gksudo:

 (gksudo:31935): Gtk-WARNING **: cannot open display: 

    I tried

 xhost +

which is simply not recognized as a command (and in any case would be a security issue).

I also tried to copy

./Xauthority

to

/root/

which also didn't work and also added

session optional pam_xauth.so

to

/etc/pam.d/su

and it didn't work.



Also, please, no hurt, no kill!

Last edited by navi_se (2015-07-17 22:18:56)

Offline

#2 2015-07-17 20:54:00

Buddlespit
Member
From: Chesapeake, Va.
Registered: 2014-02-07
Posts: 501

Re: [SOLVED] Running GUI app with sudo

Which sudo are you using to open a graphical app?

Offline

#3 2015-07-17 20:59:05

navi_se
Member
Registered: 2015-07-06
Posts: 135

Re: [SOLVED] Running GUI app with sudo

I simply have

sudo 1.8.13-1

so I am just doing, e.g.,

 [user@pc ~] $ sudo geany 
Geany: cannot open display

Last edited by navi_se (2015-07-17 20:59:37)

Offline

#4 2015-07-17 21:01:13

Buddlespit
Member
From: Chesapeake, Va.
Registered: 2014-02-07
Posts: 501

Re: [SOLVED] Running GUI app with sudo

You really shouldn't try to open a graphical application with just sudo. Which desktop are you running?

If I learned how to read, I would know that it's KDE. Have you tried kdesu?

Last edited by Buddlespit (2015-07-17 21:05:43)

Offline

#5 2015-07-17 21:04:25

navi_se
Member
Registered: 2015-07-06
Posts: 135

Re: [SOLVED] Running GUI app with sudo

You mean DE? I have  KDE 4.14.10 (was in my first post, altough not very visible I guess, changed it now).

Why shouldn't I use sudo to run GUI app? The problem is a lot of time an application will fail , bc it has to write  files which under regular use are protected, hence the need to run the application as a root/privileged user.

Also, I have the same problem if I do

su
su -

to login as root.

Last edited by navi_se (2015-07-17 21:06:42)

Offline

#6 2015-07-17 21:07:51

navi_se
Member
Registered: 2015-07-06
Posts: 135

Re: [SOLVED] Running GUI app with sudo

Yes, and I get similar results:

QXcbConnection: Could not connect to display IP:0.0
Aborted (core dumped)

Offline

#7 2015-07-17 21:08:18

Buddlespit
Member
From: Chesapeake, Va.
Registered: 2014-02-07
Posts: 501

Re: [SOLVED] Running GUI app with sudo

OK, you can't log in as root, either? Good, we're making progress.... Have you read this?
https://wiki.archlinux.org/index.php/Sudo#kdesu

Offline

#8 2015-07-17 21:17:03

Buddlespit
Member
From: Chesapeake, Va.
Registered: 2014-02-07
Posts: 501

Re: [SOLVED] Running GUI app with sudo

OK, try this... Log out of KDE and into a console or tty, then type:

$ sudo rm /home/username/.Xauthority

and then reboot the computer. .Xauthority will be recreated when you log back into KDE.
Every time you use sudo to run a graphical app, you'll change .Xauthority to root ownership. Always use a graphical su (kdesu/gksu), which will hide your .Xauthority in tmp

Offline

#9 2015-07-17 21:18:59

navi_se
Member
Registered: 2015-07-06
Posts: 135

Re: [SOLVED] Running GUI app with sudo

No, I can login as root just fine and do anything but lunch gui apps. Both via

 su 

or in a separate tty terminal or at the login (login manager is XDM).

Setting

[super-user-command]
super-user-command=sudo

gives me no changes.

Offline

#10 2015-07-17 21:30:59

navi_se
Member
Registered: 2015-07-06
Posts: 135

Re: [SOLVED] Running GUI app with sudo

Ok, it does work (it launches the application)! Thanks! I was used to ubuntu where you'd just sudo the app to make it work with root privileges.

Last edited by navi_se (2015-07-17 21:31:12)

Offline

#11 2015-07-17 21:32:40

Buddlespit
Member
From: Chesapeake, Va.
Registered: 2014-02-07
Posts: 501

Re: [SOLVED] Running GUI app with sudo

Anytime!

Offline

Board footer

Powered by FluxBB