opening gedit using root

Whenever i try sudo gedit I get:

Cannot open display:
Run ‘gedit --help’ to see a full list of available command line options.

I have run gedit --help and have found nothing to help me open gedit. Please let me know if I missed something or how I can open gedit as root.

Hi Kyluke,

If you log in as root, “su” in a terminal emulator, such as the GNOME Terminal, and then once as root, type “gnomesu gedit”, this should open gedit as root.

Hope this helps

Hi Kyluke,

A further note to this. There is actually a desktop specificity to this. If you are using gnome or KDE, then to open gedit as root you type (as a regular user):

  • if using Gnome:

gnomesu gedit

.

  • if using KDE :

kdesu gedit

and in both cases enter root password when prompted.

The same is true for opening any other apps with root permissions. As a regular user, in KDE type “kdesu application” and in Gnome type “gnomesu application”.

What you may find interesting is the LXDE desktop is different. If using LXDE, you can simply first type “su” (or “su -” ) and then type the ‘application’ and there is no need for an lxdesu or anything like that.

For example to open the application ‘leafpad’ with root permissions

  • in KDE I type: kdesu leafpad
  • in Gnome I type: gnomesu leafpad
  • in LXDE I type: su -c leafpad

… and I enter root password when prompted for a password.

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

gnomesu gedit

Good luck.

On 06/06/2011 09:06 AM, Kyluke wrote:
>
> Whenever i try sudo gedit I get:
>
> Cannot open display:
> Run ‘gedit --help’ to see a full list of available command line
> options.
>
> I have run gedit --help and have found nothing to help me open gedit.
> Please let me know if I missed something or how I can open gedit as
> root.
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.15 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJN7PPLAAoJEF+XTK08PnB5eUcQAIXJ8Pwhz6gO7G75AG8jMmAe
UdlAKSrH5V44LPD88F1FzaKdhhxWKx80lU1KePQPZPJTKBRPTYrqHaLKe4+lkzZm
BMUDVJ+HozvJnTOZrjgKyU5beuQLl1xeGYZJHrflTdCnGYGuH3GDXXb16CDcNkYz
/FYBJkKQhhMoqqqn3fnGh4HVAcnI7m37zC1utBuR/HLa0kiIcJfoxvaPSpfYFwwS
Wp/WIfZ875DFWl88+3KTpSSHavyAra2sZgRovThBaSoa8RU8QLSLGwkXfhmHHgS4
OY34441CEJA+PZxkDK/yhRweMR2oLYwodD4Dwzpn04ih7aXE6fPYyeOrr7zt/YsG
aAuBTD2sv2r0TK57xAMjAUXxA0euxl1b9vtxxDgHhy/I8VsNfz1ySkCy5fHep4O+
dpJCUK15OYGe6qwmYD4HdezTvjjFI2HjHQggKsodlEuepltBJThNLimddXu4Jo70
58nUpMzPW1Qy3XKNX5I9zMfwDB+jwgI2sELioxXKDcBGBzi7mgjedTr3bvNFjbyu
fcFY1mu4VdGMfOEv9S/5xFn9QSBV/HD3NMs3fEp4wbBlkBYv6GTX6v3zbidUjAig
RI1ZQh99+8JnhD0VcuZMCY/IIEc8o36wtl4mHz2eeGCrVprlOi2jVO0IpBorgOg8
HCqD//quntAmEvi6sDL+
=Za/5
-----END PGP SIGNATURE-----

AAH thank you so much guys!!

On 06/06/2011 05:36 PM, DawthLasu wrote:

> If you log in as root, “su” in a terminal emulator, such as the GNOME
> Terminal, and then once as root, type “gnomesu gedit”, this should open
> gedit as root.

two little problems with that information:

  1. to become root in a terminal one should use “su -” and not “su”, see
    http://tinyurl.com/ydbwssh

  2. it is unnecessary to become root in the terminal prior to issuing
    “gnomesu gedit”…that entered into a user terminal will prompt a popup
    asking for the root password, and if that successful gedit will open
    with root powers… see


dd CAVEAT: http://is.gd/bpoMD
via NNTP openSUSE 11.4 [2.6.37.6-0.5] + KDE 4.6.0 + Thunderbird 3.1.10
Acer Aspire One D255, 1.66 GHz Atom, 1 GB RAM, Intel Pineview graphics

  • When your gecko is broken you have a reptile dysfunction! *

oldcpu wrote:
> - in LXDE I type: su -c leafpad
There is also a very generic desktop independent xdg-su from the package
xdg-utils (for graphical applications), the benefit (if it is one) compared
to su is it opens a graphical password dialog, so you need no terminal and
it can directly be used with [ALT] [F2].


PC: oS 11.3 64 bit | Intel Core2 Quad Q8300@2.50GHz | KDE 4.6.3 | GeForce
9600 GT | 4GB Ram
Eee PC 1201n: oS 11.4 64 bit | Intel Atom 330@1.60GHz | KDE 4.6.0 | nVidia
ION | 3GB Ram

DenverD wrote:
> On 06/06/2011 05:36 PM, DawthLasu wrote:
>
>> If you log in as root, “su” in a terminal emulator, such as the GNOME
>> Terminal, and then once as root, type “gnomesu gedit”, this should open
>> gedit as root.
>
> two little problems with that information:
>
> 1. to become root in a terminal one should use “su -” and not “su”, see
> http://tinyurl.com/ydbwssh
>
> 2. it is unnecessary to become root in the terminal prior to issuing
> “gnomesu gedit”…that entered into a user terminal will prompt a popup
> asking for the root password, and if that successful gedit will open
> with root powers… see

Plus the first large problem:

  1. log in as root - NO, NO, NO

On 06/06/2011 05:46 PM, martin_helm wrote:
> There is also a very generic desktop independent xdg-su from the package
> xdg-utils (for graphical applications), the benefit (if it is one) compared
> to su is it opens a graphical password dialog, so you need no terminal and
> it can directly be used with [ALT] [F2].

as can both kdesu and gnomesu thusly:

  1. alt+F2
  2. type for example “kdesu kwrite” or “gnomesu gedit”
  3. type root password into GUI password dialog
  4. kwrite/gedit opens (no terminal required)

and, now there is a third way to be entered onto line two above:

xdg-su -c [kwrite/gedit/etc]

which is only half again as long (four key strokes longer than kdesu)
for kde, but only two more strokes than gnomesu


dd CAVEAT: http://is.gd/bpoMD
via NNTP openSUSE 11.4 [2.6.37.6-0.5] + KDE 4.6.0 + Thunderbird 3.1.10
Acer Aspire One D255, 1.66 GHz Atom, 1 GB RAM, Intel Pineview graphics

  • When your gecko is broken you have a reptile dysfunction! *

DenverD wrote:
> as can both kdesu and gnomesu
which you don’t need on a plain x11/openbox/fluxbox/lxde for example, that
was my point just to make it more clear (of course you can install kdesu or
gnomesu there but it makes not too much sense to install something with more
dependencies if you have already a tool which does the same job without
additional dependencies).
On kde of course I use kdesu not xdg-su -c.


PC: oS 11.3 64 bit | Intel Core2 Quad Q8300@2.50GHz | KDE 4.6.3 | GeForce
9600 GT | 4GB Ram
Eee PC 1201n: oS 11.4 64 bit | Intel Atom 330@1.60GHz | KDE 4.6.0 | nVidia
ION | 3GB Ram

Well, that told me didn’t it. Least I learnt something new.

Thanks for the tips.

On 06/06/2011 06:34 PM, martin_helm wrote:

> On kde of course I use kdesu not xdg-su -c.

but you can use either…
i wasn’t trying to say you were introducing anything wrong…just a
third way…and a GREAT way since it is desktop agnostic…


dd CAVEAT: http://is.gd/bpoMD
via NNTP openSUSE 11.4 [2.6.37.6-0.5] + KDE 4.6.0 + Thunderbird 3.1.10
Acer Aspire One D255, 1.66 GHz Atom, 1 GB RAM, Intel Pineview graphics

  • When your gecko is broken you have a reptile dysfunction! *

On 06/06/2011 07:06 PM, DawthLasu wrote:
>
> Well, that told me didn’t it. Least I learnt something new.

that was my whole point, not to “tell you” but to let you (and all those
who follow in this thread learn the more correct info for openSUSE (i
know some other distros do things differently)…ok?

> Thanks for the tips.

and, when i make technical mistakes (which the next person in the thread
might wanna follow) i’d expect you to shine the light on the
facts–helps everyone involved…right?


dd CAVEAT: http://is.gd/bpoMD
via NNTP openSUSE 11.4 [2.6.37.6-0.5] + KDE 4.6.0 + Thunderbird 3.1.10
Acer Aspire One D255, 1.66 GHz Atom, 1 GB RAM, Intel Pineview graphics

  • When your gecko is broken you have a reptile dysfunction! *

@DenverD
I forgot to add some smiley or so when I answered. By the way I use kdesu
exactly for the reason you mentioned - it saves a few keystrokes and I am
incredibly lazy :wink:


PC: oS 11.3 64 bit | Intel Core2 Quad Q8300@2.50GHz | KDE 4.6.3 | GeForce
9600 GT | 4GB Ram
Eee PC 1201n: oS 11.4 64 bit | Intel Atom 330@1.60GHz | KDE 4.6.0 | nVidia
ION | 3GB Ram

On 06/06/2011 07:39 PM, martin_helm wrote:
> @DenverD
> I forgot to add some smiley or so when I answered. By the way I use kdesu
> exactly for the reason you mentioned - it saves a few keystrokes and I am
> incredibly lazy :wink:
>
not as lazy as me, i’m trying to figure out how to make this alias work:

alias g=‘xdg-su -c’

which works in a terminal thusly

g kwrite

launches a gui password prompt, and then a root powered kwrite…

however, it doesn’t work from Alt+F2, and i can’t divine why, can you?


dd CAVEAT: http://is.gd/bpoMD
via NNTP openSUSE 11.4 [2.6.37.6-0.5] + KDE 4.6.0 + Thunderbird 3.1.10
Acer Aspire One D255, 1.66 GHz Atom, 1 GB RAM, Intel Pineview graphics

  • When your gecko is broken you have a reptile dysfunction! *

DenverD wrote:
> however, it doesn’t work from Alt+F2, and i can’t divine why, can you?
>
Same here, but I simply do not know which configuration files are read when
[ALT][F2] is used.
What about a script named g and put it into ~/bin?


#/bin/sh
xdg-su -c "$@"

(and yes this is a nasty, there is for sure a better solution which I do not
see right now)


PC: oS 11.3 64 bit | Intel Core2 Quad Q8300@2.50GHz | KDE 4.6.3 | GeForce
9600 GT | 4GB Ram
Eee PC 1201n: oS 11.4 64 bit | Intel Atom 330@1.60GHz | KDE 4.6.0 | nVidia
ION | 3GB Ram

No you’re right, it was my mistake, and now I know the better way to do it :slight_smile:

I’ll be watching to see if you and Martin get that alias of yours working, I’ve just been learning on aliases in the modprobe.conf for LPI Certification I’m working towards :slight_smile:

On 06/06/2011 08:27 PM, martin_helm wrote:
>


> #/bin/sh
> xdg-su -c "$@"
> 

hmmm…
i commented out my alias and put the above in my bin… and it works
fine in a terminal, but (again) doesn’t work from Alt+F2…


dd CAVEAT: http://is.gd/bpoMD
via NNTP openSUSE 11.4 [2.6.37.6-0.5] + KDE 4.6.0 + Thunderbird 3.1.10
Acer Aspire One D255, 1.66 GHz Atom, 1 GB RAM, Intel Pineview graphics

  • When your gecko is broken you have a reptile dysfunction! *

On 06/06/2011 10:06 PM, DawthLasu wrote:
>
> I’ll be watching to see if you and Martin get that alias of yours
> working, I’ve just been learning on aliases in the modprobe.conf for LPI
> Certification I’m working towards :slight_smile:

yep, i don’t understand why Alt+F2 won’t accept a ‘perfectly good’
alias… (and, i have no idea what an LPI Certification is!)


dd CAVEAT: http://is.gd/bpoMD
via NNTP openSUSE 11.4 [2.6.37.6-0.5] + KDE 4.6.0 + Thunderbird 3.1.10
Acer Aspire One D255, 1.66 GHz Atom, 1 GB RAM, Intel Pineview graphics

  • When your gecko is broken you have a reptile dysfunction! *

It’s a certification that basically says “I can do Linux, me” from the Linux Professional Institute. I’ve always wanted to do more with Linux, and now I’m finally getting round to it :slight_smile: