You are not logged in.

#1 2017-01-03 06:54:15

vaibhavsingh97
Member
Registered: 2016-08-15
Posts: 32

How to resolve “No protocol specified Unable to init server:? [Solved]

I installed arch linux lats night. Now i don't understand why I can't run GUI applications like gedit,.etc from a terminal.

[vaibhav@linux ~]$ sudo gedit 
[sudo] password for vaibhav: 
No protocol specified
Unable to init server: Could not connect: Connection refused
   
(gedit:850): Gtk-WARNING **: cannot open display: :0 

but when i use this command after every boot/reboot

[vaibhav@linux ~]$ xhost +local:
non-network local connections being added to access control list

I am able to run GUI application. How to fix this permanently?

Last edited by vaibhavsingh97 (2017-01-03 08:56:10)

Offline

#2 2017-01-03 07:36:37

ayekat
Member
Registered: 2011-01-17
Posts: 1,617

Re: How to resolve “No protocol specified Unable to init server:? [Solved]

vaibhavsingh97 wrote:

Now i don't understand why I can't run GUI applications like gedit,.etc from a terminal.

It is perfectly possible to run GUI applications from the terminal - but you are running them with `sudo`, which you should not.
It does not work because by default your X session is only accessible to your own user - this is a security mechanism to prevent other users from doing malicious things in your X session. Disabling that mechanism the way you did with `xhost` is therefore not recommended.

As stated in the above link, if you want to run the application with elevated privileges, there is gksu/gksudo for that job.

--edit--
+1 for seth's suggestion below.

Last edited by ayekat (2017-01-03 08:41:24)


pkgshackscfgblag

Offline

#3 2017-01-03 08:39:45

seth
Member
Registered: 2012-09-03
Posts: 62,331

Re: How to resolve “No protocol specified Unable to init server:? [Solved]

That aside, look into sudoedit for this particular case - running GUI applications as root is never a good idea. (They contain too much code, have too many dependencies and are in general far more bug and exploit prone)

Offline

#4 2017-01-04 11:04:30

vaibhavsingh97
Member
Registered: 2016-08-15
Posts: 32

Re: How to resolve “No protocol specified Unable to init server:? [Solved]

ayekat wrote:
vaibhavsingh97 wrote:

Now i don't understand why I can't run GUI applications like gedit,.etc from a terminal.

It is perfectly possible to run GUI applications from the terminal - but you are running them with `sudo`, which you should not.
It does not work because by default your X session is only accessible to your own user - this is a security mechanism to prevent other users from doing malicious things in your X session. Disabling that mechanism the way you did with `xhost` is therefore not recommended.

As stated in the above link, if you want to run the application with elevated privileges, there is gksu/gksudo for that job.

--edit--
+1 for seth's suggestion below.

[vaibhav@linux ~]$ gksu bleachbit 
Could not open X display
[vaibhav@linux ~]$ gksudo bleachbit 
Could not open X display

what to do know?

Offline

#5 2017-01-04 11:20:02

Mr.Elendig
#archlinux@freenode channel op
From: The intertubes
Registered: 2004-11-07
Posts: 4,097

Re: How to resolve “No protocol specified Unable to init server:? [Solved]

For editors use sudoedit instad of running the editor as root, (or use thriks like :w !sudo tee %  in vim)


Evil #archlinux@libera.chat channel op and general support dude.
. files on github, Screenshots, Random pics and the rest

Offline

#6 2017-01-04 11:29:59

Docbroke
Member
From: India
Registered: 2015-06-13
Posts: 1,438

Re: How to resolve “No protocol specified Unable to init server:? [Solved]

I think OP is trying to open GUI applications from server (without x server running)

Offline

#7 2017-01-04 12:11:18

ayekat
Member
Registered: 2011-01-17
Posts: 1,617

Re: How to resolve “No protocol specified Unable to init server:? [Solved]

Docbroke wrote:

I think OP is trying to open GUI applications from server (without x server running)

It does seem so. Or from a TTY or another terminal that does not have access to the X display.

Please post the output of these commands:

pgrep -a X
echo $DISPLAY
echo $TERM

pkgshackscfgblag

Offline

#8 2017-01-04 13:35:36

vaibhavsingh97
Member
Registered: 2016-08-15
Posts: 32

Re: How to resolve “No protocol specified Unable to init server:? [Solved]

ayekat wrote:
Docbroke wrote:

I think OP is trying to open GUI applications from server (without x server running)

It does seem so. Or from a TTY or another terminal that does not have access to the X display.

Please post the output of these commands:

pgrep -a X
echo $DISPLAY
echo $TERM
[vaibhav@linux ~]$ pgrep -a X
410 /usr/bin/Xwayland :1024 -rootless -noreset -listen 4 -listen 5 -displayfd 6
581 /usr/bin/Xwayland :0 -rootless -noreset -listen 4 -listen 5 -displayfd 6
[vaibhav@linux ~]$ echo $DISPLAY
:0
[vaibhav@linux ~]$ echo $TERM
xterm-256color
[vaibhav@linux ~]$ 

Offline

#9 2017-01-04 14:00:23

seth
Member
Registered: 2012-09-03
Posts: 62,331

Re: How to resolve “No protocol specified Unable to init server:? [Solved]

/usr/bin/Xwayland

gksu etc. does currently not work on wayland, use gnome on xorg, but
a) avoid running GUI processes as root as much as you can anyway
b) DO NOT USE BLEACHBIT AT ALL - it randomly breaks things because the authors have seriously no deeper knowledge of what they're doing. At very best, it will make your system *slower*.
https://blog.martin-graesslin.com/blog/ … bleachbit/
https://lwn.net/Articles/313679/

Offline

Board footer

Powered by FluxBB