-2

When I try to open synaptic via the command line, I got this:

user@hostname ~ $ sudo synaptic
[sudo] password for user: 
No protocol specified

** (synaptic:4516): WARNING **: Could not open X display
No protocol specified
error: XDG_RUNTIME_DIR not set in the environment.

(synaptic:4516): Gtk-WARNING **: cannot open display: :0

What should I do?

Vicky Tiwari
  • 11
  • 1
  • 1

1 Answers1

2

Your shell environment is for some reason missing the DISPLAY variable. A quick workaround would be the following call:

$ DISPLAY=:0 sudo synaptic

A more advanced and secure variant, for the reasons described below by sudodus, would be to use a graphical sudo frontend:

$ export DISPLAY=:0; gksudo synaptic

However, this will be of no use if you don't have an X server running, e. g. because you're running a headless system or you're in runlevel 1. You'll need to use apt-get instead of some graphical frontend then.

Murphy
  • 1,677
  • 1
    You should never use plain sudo with graphical user interface programs. Instead you should use the command sudo -H gui-program-name . This prevents the root user from hijacking files in your user-ID's home directory. An alternative is to install the package gksuand use gksudo gui-program-name – sudodus Sep 14 '17 at 11:27