Saturday, May 4, 2024
 Popular · Latest · Hot · Upcoming
51
rated 0 times [  51] [ 0]  / answers: 1 / hits: 288610  / 2 Years ago, wed, december 29, 2021, 6:19:17

When I am running some software using sudo command it showing error like



cannot connect to X server


For example if I run the following command:



$ sudo gedit /etc/profile


I am getting following command



(gedit:6758): WARNING **: Command line `dbus-launch --autolaunch=84b871d735f31ffe014dc9ba00000009 --binary-syntax --close-stderr' 
exited with non-zero exit status 1:
Autolaunch error: X11 initialization failed.
Cannot open display:
Run 'gedit --help' to see a full list of available command line options.


Or if I am running super-boot-manager I am getting following error



buc: cannot connect to X server


Please help.


More From » display

 Answers
7

You need to allow the root user access to the X server:



xhost local:root


And point the command to the right DISPLAY:



sudo DISPLAY=$DISPLAY gedit /etc/profile

[#36177] Friday, December 31, 2021, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
nerta

Total Points: 414
Total Questions: 103
Total Answers: 97

Location: England
Member since Wed, Apr 19, 2023
1 Year ago
;