You are not logged in.

#1 2012-12-04 18:42:15

ssivil
Member
Registered: 2011-09-23
Posts: 28

gedit fails to open as root in terminal

When I start a terminal, I enter "su -"

When I try to open any file, or simply enter gedit, I get:
========================================
** (gedit:1216): WARNING **: Could not open X display
Cannot open display:
========================================
Can someone please help?

Thank you.

Offline

#2 2012-12-04 18:49:55

illusionist
Member
From: localhost
Registered: 2012-04-03
Posts: 498

Re: gedit fails to open as root in terminal

What DE/WM you are using ?


  Never argue with stupid people,They will drag you down to their level and then beat you with experience.--Mark Twain
@github

Offline

#3 2012-12-04 18:56:23

WorMzy
Forum Moderator
From: Scotland
Registered: 2010-06-16
Posts: 11,783
Website

Re: gedit fails to open as root in terminal

Expected behaviour.

I recommend that you use sux, rather than 'su -'.


Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD

Making lemonade from lemons since 2015.

Offline

#4 2012-12-04 19:16:12

alphaniner
Member
From: Ancapistan
Registered: 2010-07-12
Posts: 2,810

Re: gedit fails to open as root in terminal

The env variable DISPLAY is the key.  Try sudo -i instead:

$ su -
# env |grep DISPLAY
# leafpad
leafpad: Cannot open display: 
# exit
$ sudo -i
# env |grep DISPLAY
DISPLAY=:0.0
# leafpad
<leafpad opens>

###

WorMzy wrote:

I recommend that you use sux

sux?  Wuzzat?

Last edited by alphaniner (2012-12-04 19:19:23)


But whether the Constitution really be one thing, or another, this much is certain - that it has either authorized such a government as we have had, or has been powerless to prevent it. In either case, it is unfit to exist.
-Lysander Spooner

Offline

#5 2012-12-04 19:23:47

stressat
Member
From: Romania
Registered: 2010-10-10
Posts: 73
Website

Re: gedit fails to open as root in terminal

sux - wrapper around su which will transfer your X credentials

Use su (not su -), or sux, or sudo (sudo su, sudo -s, sudo -i).

su > gives you root permissions but it does not change the PATH variable and current working directory

su - > changes the PATH too... and root's home becomes your current working directory

Last edited by stressat (2012-12-04 19:27:53)

Offline

#6 2012-12-04 19:24:18

2ManyDogs
Forum Moderator
Registered: 2012-01-15
Posts: 4,645

Re: gedit fails to open as root in terminal

alphaniner wrote:

sux?  Wuzzat?

Assuming you're not joking:

ArchWiki wrote:

sux (wrapper around su which will transfer your X credentials)

$ sux root name-of-app

https://wiki.archlinux.org/index.php/Ru … ps_as_root

(edit) snaked again...

Last edited by 2ManyDogs (2012-12-04 19:24:39)


How to post. A sincere effort to use modest and proper language and grammar is a sign of respect toward the community.

Offline

#7 2012-12-04 19:32:44

alphaniner
Member
From: Ancapistan
Registered: 2010-07-12
Posts: 2,810

Re: gedit fails to open as root in terminal

I wasn't joking, but now I realize I should have worked out what it was.  sux = su + X, naturally!  This is Linux after all!


But whether the Constitution really be one thing, or another, this much is certain - that it has either authorized such a government as we have had, or has been powerless to prevent it. In either case, it is unfit to exist.
-Lysander Spooner

Offline

#8 2012-12-04 19:40:33

anonymous_user
Member
Registered: 2009-08-28
Posts: 3,059

Re: gedit fails to open as root in terminal

Do not forget about gksu(do) for launching GUI applications as root.

Offline

#9 2012-12-04 19:54:11

ssivil
Member
Registered: 2011-09-23
Posts: 28

Re: gedit fails to open as root in terminal

illusionist wrote:

What DE/WM you are using ?

Gnome.  Both Metacity and Mutte are installed.

In the past (before systemd), gedit never game me problems when entering su - in a terminal.

The DISPLAY=:0.0 didn't help.

Thanks in advance.

Offline

#10 2012-12-04 19:57:36

loafer
Member
From: the pub
Registered: 2009-04-14
Posts: 1,772

Re: gedit fails to open as root in terminal

Something else which is entirely the fault of systemd!


All men have stood for freedom...
For freedom is the man that will turn the world upside down.
Gerrard Winstanley.

Offline

#11 2012-12-04 21:08:19

WorMzy
Forum Moderator
From: Scotland
Registered: 2010-06-16
Posts: 11,783
Website

Re: gedit fails to open as root in terminal

Yeaaaaah, if it worked before it was a bug.

from 'man su'

       -, -l, --login
              Starts the shell as login shell with an environment similar to a real login:

                 o      clears all environment variables except for TERM

                 o      initializes the environment variables HOME, SHELL, USER, LOGNAME, PATH

                 o      changes to the target user's home directory

                 o      sets argv[0] of the shell to '-' in order to make the shell a login shell

Note the first bullet point. This includes $DISPLAY.

Last edited by WorMzy (2012-12-04 21:08:42)


Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD

Making lemonade from lemons since 2015.

Offline

#12 2012-12-06 05:30:34

illusionist
Member
From: localhost
Registered: 2012-04-03
Posts: 498

Re: gedit fails to open as root in terminal

ssivil wrote:

The DISPLAY=:0.0 didn't help.

Thanks in advance.

It should be DISPLAY=:0
Is your problem related to recent dbus update ? , I am not sure but there are some discussions going on . You may take a look at those.


  Never argue with stupid people,They will drag you down to their level and then beat you with experience.--Mark Twain
@github

Offline

#13 2012-12-06 08:43:41

scar
Member
From: Hungary
Registered: 2009-10-01
Posts: 442

Re: gedit fails to open as root in terminal

for god's sake, try gksu...


“The future has already arrived. It's just not evenly distributed yet.”
― William Gibson

Offline

#14 2012-12-06 09:56:04

illusionist
Member
From: localhost
Registered: 2012-04-03
Posts: 498

Re: gedit fails to open as root in terminal

scar wrote:

for god's sake, try gksu...

LOL.... big_smile


  Never argue with stupid people,They will drag you down to their level and then beat you with experience.--Mark Twain
@github

Offline

#15 2012-12-06 10:21:04

blue sea & blue sail
Member
Registered: 2012-12-06
Posts: 21

Re: gedit fails to open as root in terminal

ssivil wrote:

When I start a terminal, I enter "su -"

When I try to open any file, or simply enter gedit, I get:
========================================
** (gedit:1216): WARNING **: Could not open X display
Cannot open display:
========================================
Can someone please help?

Thank you.

sudo gedit


Acer TM B115-P5BB | intel video card |Seagate 500G 5400rpm AF 7.5mm | 2GB RAM | 2.5 GHz Pentium N3530 CPU

Offline

#16 2012-12-06 10:35:18

loafer
Member
From: the pub
Registered: 2009-04-14
Posts: 1,772

Re: gedit fails to open as root in terminal

Can't a command like "sudo gedit" cause issues with the permissions on e.g. .ICEauthority changing?  Or is this not a problem anymore?


All men have stood for freedom...
For freedom is the man that will turn the world upside down.
Gerrard Winstanley.

Offline

#17 2012-12-06 11:40:18

blue sea & blue sail
Member
Registered: 2012-12-06
Posts: 21

Re: gedit fails to open as root in terminal

loafer wrote:

Can't a command like "sudo gedit" cause issues with the permissions on e.g. .ICEauthority changing?  Or is this not a problem anymore?

oh. I see. Thinks a lot.


Acer TM B115-P5BB | intel video card |Seagate 500G 5400rpm AF 7.5mm | 2GB RAM | 2.5 GHz Pentium N3530 CPU

Offline

#18 2012-12-07 03:20:56

David Batson
Member
Registered: 2011-10-13
Posts: 640

Re: gedit fails to open as root in terminal

Offline

Board footer

Powered by FluxBB