Cannot open GUI programs as root

Just switched over to OpenSUSE with great results. Everything has gone smoothly, with the exception of this “cannot open display” problem. Basically I can’t open any GUI programs in root with “sudo gedit” or “gksudo firefox”. :confused: Every time I type something like that into the terminal, I get:

$ sudo geany
Geany: cannot open display

But I can execute non-gui programs just fine, like nano or lspci.

So what gives? I would imagine that root simply doesn’t have access to X11 since my regular user has the privileges, but I don’t know how to fix this.
Any help is appreciated:)

There are special commands for that kdesu for kde, gnomesu for gnome,
xdg-su -c for everything.


PC: oS 12.1 x86_64 | i7-2600@3.40GHz | 16GB | KDE 4.8.4 | GeForce GT 420
ThinkPad E320: oS 12.1 x86_64 | i3@2.30GHz | 8GB | KDE 4.8.4 | HD 3000
eCAFE 800: oS 12.1 i586 | AMD Geode LX 800@500MHz | 512MB | KDE 3.5.10

I’ve found that many GUI programs won’t launch using only kdesu. In this forum archives (I remember at least one originated by me years ago) it was revealed that you need to implement a number of switches as well or you’ll experience dbus-related errors.

Assume would be the same for the other commands.

TSU

Am 17.07.2012 00:26, schrieb tsu2:
> I’ve found that many GUI programs won’t launch using only kdesu.
I never had to implement a switch to run something with kdesu when
running within a kde session (which is the use case kdesu is made for).

Can you give an example?


PC: oS 12.1 x86_64 | i7-2600@3.40GHz | 16GB | KDE 4.8.4 | GeForce GT 420
ThinkPad E320: oS 12.1 x86_64 | i3@2.30GHz | 8GB | KDE 4.8.4 | HD 3000
eCAFE 800: oS 12.1 i586 | AMD Geode LX 800@500MHz | 512MB | KDE 3.5.10

There are special commands for that kdesu for kde, gnomesu for gnome,
xdg-su -c for everything.

kdesu works just great, can’t believe I didn’t know about this! (Being a user of KDE for some time now)
Thanks :slight_smile:

On 07/17/2012 07:06 AM, akbrucke wrote:
> can’t believe I didn’t know about this!

its an “openSUSE thing”…you may have heard that “Linux is Linux” but
it isn’t true…each distribution has their own little differences
(otherwise there would only be One Linux)…

since you are using sudo in ways we don’t normally (in openSUSE) do, i
assume you come from Ubuntu or one of its children (Mint, Kbuntu, etc
etc etc), so you will probably be happy to read though some other
differences, here:
http://tinyurl.com/ubuntu-to-openSUSE
http://tinyurl.com/Ubuntu-Differences

and, the warning in post #3 to this thread can be ignored until someone
produces an example in a currently supported version, correctly
installed and administered…(that is to say that it is possible for a
neophyte administrator to damage his/her system in ways that make kdesu,
gnomesu, sudo and su all appear to be broken…in fact about a year
ago there was a guy/gal here who had made LOTs of changes to critical
conf files trying to force openSUSE to allow him to [for example] do “$
sudo geany” and then after making all the changes to ‘fix’ his system,
he was absolutely sure he didn’t need to use kdesu because it didn’t
work on his self-murdered system as we said it should…)


dd

As Martin allready indicated, you forgot to tell which desktop you use (KDE, Gnome, …) while it is obvious you use a GUI, else you would have a question about GUI programs. Please do not leave people here guessing about such an obvious thing next time.

Try the kdesu/gnomesu commands (as Martins tells you), read this: SDB:Login as root - openSUSE and try to avoid root usage as much a possible. I say this because the only GUI programs I ever start as root are YaST (which does this out of itself), a terminal (for wich there is an entry in the main menu > System > Terminal for this purpose in KDE) and maybe a file manager (for which there is also an entry in the KDE main menu > System > File manager). And thus the need for using kdesu for me is nil.

Another way to start applications as root is to use ‘sux’. klik - sux Linux Software Download
Now I can’t say for Suse, but in other distros I have used it a lot.
This is a small wrapper to ‘su’ which sets the needed environmental stuff.
You then open a terminal - **not **root terminal! - and issue command sux.
Now you are root and you should be able to launch any program as root. (All warnings about doing this is already given earlier in thread.)

On 2012-07-17 14:26, pingu 2 wrote:
>
> Another way to start applications as root is to use ‘sux’. ‘klik - sux
> Linux Software Download’ (http://sux.klik.atekon.de/)
> Now I can’t say for Suse, but in other distros I have used it a lot.
> This is a small wrapper to ‘su’ which sets the needed environmental
> stuff.

‘sux’ was included years ago in openSUSE, but it has been superseded by plain ‘su’. You do not
need ‘sux’ here.


Cheers / Saludos,

Carlos E. R.
(from 11.4 x86_64 “Celadon” at Telcontar)

On 07/17/2012 02:26 PM, pingu 2 wrote:
>
> Another way to start applications as root is to use ‘sux’. ‘klik - sux
> Linux Software Download’ (http://sux.klik.atekon.de/)
> Now I can’t say for Suse, but in other distros I have used it a lot.

here, instead of adding the sux package and then issuing “sux” at a
command line in a user terminal…just don’t add anything and issue this
in a user terminal


su -

and give the root password when asked…

what could be simpler?


dd

Since OP got message

$ sudo geany
Geany: cannot open display

I assumed it was a problem with some environmental switches, also tsu2 suggested something in that direction.
That’s why I suggested ‘sux’ which solves that kind of issues.
But of course, if ‘su’ does all that ‘sux’ does, then the problem is somewhere else.

On 07/18/2012 12:46 PM, pingu 2 wrote:
> if ‘su’ does all that ‘sux’ does, then the problem is
> somewhere else.

su does not do all that ‘sux’ does…

but “su -” does all that needs to be done (including change from the
user to root’s environment)

note: do NOT overlook the differences between these two commands


su
su -

the first gives root powers while retaining the user’s environment
the second gives both root power and environment…

also please do not lose sight of the actual ‘problem’ of this thread,
which is ‘solved’ not by using, ‘sux’, ‘su’ or even ‘su -’ but rather
exactly as Martin gave in his post #2

that is to say: there was no problem except a lack of understanding or
knowledge by the OP of the way openSUSE (and, i think SUSE Linux
Enterprise) operating systems approaches the task of launching GUI
applications with root powers in a user’s desktop environment [other
distributions do that with sudo, or sux or i do not know what all the
others use]


dd