unable to open a file in gedit from the terminal when I login as root

0

When I try to open a file named tester.php from gedit by logging in as root, I see this :

[root@Feddy htdocs]# gedit tester.php

(gedit:4310): EggSMClient-WARNING **: Failed to connect to the session manager: None of the authentication protocols specified are supported


** (gedit:4310): WARNING **: Could not connect to session bus

What is this message and why do I get this ?

NOTE: I am able to open the file by the same command

gedit tester.php

when I act as a regular user. (i.e not root)

Suhail Gupta

Posted 2013-01-09T05:46:20.953

Reputation: 1 655

Answers

2

By default, and for security reasons, the only user that interacts with X-server is the logged-in user. Meaning, You can not initiate a connection to x-server as a different user or in your case as root, unless you have overridden the default setting to allow different users/hosts to connect to x-server. So the error message you are getting is related to x-server since any other user can't connect to it. In order to get around it, you have various fixes you can apply. What I normally do when ever I need to run an X-app as root is as follows.

  • From normal user terminal, I run xhost + to grant access to all user temporarily
  • Then I log in as root from a different terminal and execute the X-app ie gedit tester.php

To make it permanent (which I don't suggest), edit /etc/profile and add the following line:

export XAUTHORITY=/root/.Xauthority

WeloSefer

Posted 2013-01-09T05:46:20.953

Reputation: 330

The same message..Here is a shot of what I did

– Suhail Gupta – 2013-01-09T10:34:43.567

instead of su do su - – WeloSefer – 2013-01-09T15:58:18.707

yeah it worked ! Thank you. Can you please tell me the difference between su and su - – Suhail Gupta – 2013-01-26T07:20:47.763

also is there any time duration till I will be able to open a file directly from terminal as root ? – Suhail Gupta – 2013-01-26T07:23:09.477

The use of the hyphen "-" forces the new shell connection to run with adjustment of variables environment and all the default settings according to user preferences. – WeloSefer – 2013-01-26T21:01:22.540

as long as you don't disable the access by invoking xhost - from normal user prompt and don't restart, it should still work – WeloSefer – 2013-01-26T21:02:47.563