unable to open a file in gedit from the terminal when I login as root
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
Related videos on Youtube
Suhail Gupta
Updated on September 18, 2022Comments
-
Suhail Gupta over 1 year
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 over 11 yearsThe same message..Here is a shot of what I did
-
WeloSefer over 11 yearsinstead of
su
dosu -
-
Suhail Gupta over 11 yearsyeah it worked ! Thank you. Can you please tell me the difference between
su
andsu -
-
Suhail Gupta over 11 yearsalso is there any time duration till I will be able to open a file directly from terminal as root ?
-
WeloSefer over 11 yearsThe 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 over 11 yearsas long as you don't disable the access by invoking
xhost -
from normal user prompt and don't restart, it should still work