You are not logged in.

#1 2007-11-14 06:18:40

Dheart
Member
From: Sofia, Bulgaria
Registered: 2006-10-26
Posts: 956

Can't run applications with GUI as root

I reinstalled my sistem recently, got it up and running and when I tried to run kwrite or any other application that has gui (for example jacman) I receive the same error:

[root@lightbringer dheart]# kwrite
No protocol specified
kwrite: cannot connect to X server :0.0
[root@lightbringer dheart]#

Running GUI applications with sudo is fine, though jacman fails to start with sudo.

However I got used to run kwrite/gedit as root in order to edit my system preferences and I'd like to be able to do so again.
Any suggestions?


My victim you are meant to be
No, you cannot hide nor flee
You know what I'm looking for
Pleasure your torture, I will endure...

Offline

#2 2007-11-14 07:12:39

ujjwal
Member
Registered: 2006-01-31
Posts: 27

Re: Can't run applications with GUI as root

Try running "xhost +" from your regular user account, then run the application as root. If it works, you can put the command in your ~/.bashrc

Offline

#3 2007-11-14 07:17:27

Dheart
Member
From: Sofia, Bulgaria
Registered: 2006-10-26
Posts: 956

Re: Can't run applications with GUI as root

Thanks! Now it works!


My victim you are meant to be
No, you cannot hide nor flee
You know what I'm looking for
Pleasure your torture, I will endure...

Offline

#4 2007-11-14 17:33:32

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: Can't run applications with GUI as root

ujjwal wrote:

Try running "xhost +" from your regular user account, then run the application as root. If it works, you can put the command in your ~/.bashrc

For the record, this is bad advice. Please don't do this.

Running GUI apps as root *shouldn't* be common place.

Offline

#5 2007-11-14 17:50:08

byte
Member
From: Düsseldorf (DE)
Registered: 2006-05-01
Posts: 2,046

Re: Can't run applications with GUI as root

XAUTHORITY=/home/<your-non-root-user>/.Xauthority kwrite

Try that.


1000

Offline

#6 2007-11-14 17:54:58

Dusty
Schwag Merchant
From: Medicine Hat, Alberta, Canada
Registered: 2004-01-18
Posts: 5,986
Website

Re: Can't run applications with GUI as root

phrakture wrote:

Running GUI apps as root *shouldn't* be common place.

I'm inclined to disagree -- if your preferred editor is a GUI app (as mine is), why should you use VIM, emacs, nano, or siblings to edit /etc/rc.conf?

Its true that GUI apps are more complex than command-line apps, and complexity can hide security flaws that might mean if you're using a GUI app as root there's a hypothetical possibility someone can gain control of your root account that wouldn't happen with a console app. Is there a documented case of this happening or is it just paranoia/FUD?

Having said that, running 'xhost +' is insecure, it can allow X connections from external systems (they'd have to know your root or user password though). Try 'xhost + localhost' instead to prevent this possibility.

Dusty

Offline

#7 2007-11-14 18:38:03

skottish
Forum Fellow
From: Here
Registered: 2006-06-16
Posts: 7,942

Re: Can't run applications with GUI as root

If you're in KDE, just use kdesu. It will allow you to launch GUIs as root from within the user account:

kdesu kwrite

Offline

#8 2007-11-14 18:47:26

Dusty
Schwag Merchant
From: Medicine Hat, Alberta, Canada
Registered: 2004-01-18
Posts: 5,986
Website

Re: Can't run applications with GUI as root

gksu and gksudo do the same thing for gnome/gtk systems.

Dusty

Offline

#9 2007-11-14 20:44:05

Dheart
Member
From: Sofia, Bulgaria
Registered: 2006-10-26
Posts: 956

Re: Can't run applications with GUI as root

@Dusty: thanks for the security advice, changed my .bashrc.

@skottish: I have kdemod installed, but I only use a few application (kwrite, kite, k3b). I'm running openbox and kdesu and gtksu are out of question (They output tons of errors that something isn't running and start slow (especially gtksu).
Besides I got used using gedit for editing sistem preferences.

@phrakture: As Dusty said it's a matter of choice - some prefer command line editors, other - GUI editors. And besides: Linux is secure enough and not to run a GUI text editor because of a theorical hole in it is something really really paranoic...


My victim you are meant to be
No, you cannot hide nor flee
You know what I'm looking for
Pleasure your torture, I will endure...

Offline

#10 2007-11-14 20:44:48

dr_te_z
Member
From: Zoetermeer, the Netherlands
Registered: 2006-12-06
Posts: 154

Re: Can't run applications with GUI as root

ssh -X -Y -C root@localhost

does the job. What's wrong with gedit-ing your /etc/whatever?


Somewhere between "too small" and "too large" lies the size that is just right.
- Scott Hayes

Offline

#11 2007-11-14 21:15:48

retsaw
Member
From: London, UK
Registered: 2005-03-22
Posts: 132

Re: Can't run applications with GUI as root

Dusty wrote:

Having said that, running 'xhost +' is insecure, it can allow X connections from external systems (they'd have to know your root or user password though).

They don't even need a password if you have done 'xhost +', but this isn't that big a risk if you are behind a firewall (on a secure network where you trust the other users), and even less of a risk if X is set not to listen to TCP connections (as is default with KDM)

Dusty wrote:

Try 'xhost + localhost' instead to prevent this possibility.

This won't work if X is set not to listen to TCP connections, but 'xhost +local:' will work.

Offline

#12 2007-11-14 21:39:10

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: Can't run applications with GUI as root

Dheart wrote:

@phrakture: As Dusty said it's a matter of choice - some prefer command line editors, other - GUI editors.

I never said it wasn't a matter of choice - I'm just saying that it shouldn't be recommended as the first way to do this. "How do I run GUI apps as root?" should probably be questioned as to why these apps can't run as a normal user _first_.

Offline

Board footer

Powered by FluxBB