Enter your search query in the box above ^, or use the forum search tool.

You are not logged in.

#1 2013-01-03 09:18:53

Registered: 2010-12-01
Posts: 46

problems with sudo: "Gtk-WARNING **: cannot open display: :0"

recently, after a regular update/upgrade (i actually were using Wheezy from a long time from Crunchbang), when i enter "sudo synaptic" at the terminal, i get:

Invalid MIT-MAGIC-COOKIE-1 key
(synaptic:3248): Gtk-WARNING **: cannot open display: :0

and the same when i try "sudo pluma", "sudo gedit", "sudo caja --no-desktop", "sudo gedit --no-desktop", etc.

from … ost4861870 i found a temporary solution, which there they say:

echo $DISPLAY                  # you'll be needing this value 3 lines below
sudo -i                        # or "su -" on older Slackwares
xauth merge ~alien/.Xauthority # use your own username here instead of "alien"
export DISPLAY=:0.0            # use the value of DISPLAY you've seen 3 lines before

the problem is this only works on the current login, and doesn't last to the next ones - do someone know how to fix this situation that lasts "forever", just like when we do fresh-install from a Crunchbang live-cd?


Be excellent to each other!

#2 2013-01-03 12:42:25

From: Poznań, Poland
Registered: 2012-12-20
Posts: 23

Re: problems with sudo: "Gtk-WARNING **: cannot open display: :0"

Beacuse you are trying to run it in terminal. Run  gmrun and type gksu synaptic.


#3 2013-01-03 18:44:25

#! Die Hard
Registered: 2010-07-02
Posts: 2,005

Re: problems with sudo: "Gtk-WARNING **: cannot open display: :0"

Or if you want to be able to run this from a terminal on a regular basis (this also works for starting graphical apps from a tty or cron job) you can just create an alias (I called the alias "tsyn" short for "terminal synaptic, you can change this to whatever you like though):

alias tsyn='sudo "DISPLAY=:0 synaptic"' 

You may have to change :0 to whatever your current display is called. In the example you showed, you can just add that to .bashrc to make it so that variable is always set in any terminal you open. You might have to do this for the root user as well, so if desired you can do it in both ~/.bashrc and /root/.bashrc.


Ideally, when you run sudo synaptic from a pts and/or xterm, it should already be aware of what display it's running on but for some reason it's not. The suggestions I made are more of a workaround than an actual fix, I'm not sure what would cause an environment variable like that to not be set.

Last edited by mynis01 (2013-01-03 18:45:47)


#4 2013-01-05 01:25:52

#! Die Hard
Registered: 2012-09-27
Posts: 1,975

Re: problems with sudo: "Gtk-WARNING **: cannot open display: :0"

bp wrote:

Beacuse you are trying to run it in terminal. Run  gmrun and type gksu synaptic.

Strange. Just out of curiosity I tried both sudo and gksu synaptic in terminal, and both is working fine for me. Only difference is that with sudo synaptic I need to enter the password in terminal, while gksu launches a input box for it. But both works fine, and synaptic-pkexec is also working in terminal...

- apt-mark hold account


#5 2013-01-05 02:26:53

#! Windbag
From: Cary, NC
Registered: 2010-12-08
Posts: 1,487

Re: problems with sudo: "Gtk-WARNING **: cannot open display: :0"

If you install


, it will run with su privaleges with the added benefit of X.

"Sometimes I wish I hadn't taken the red pill" -Me


#6 2013-01-05 03:05:36

#! Die Hard
From: Earth
Registered: 2012-10-05
Posts: 574

Re: problems with sudo: "Gtk-WARNING **: cannot open display: :0"

Fascinating! I have been having this same problem for a while now but hadn't found the time to start a thread. I forgot entirely about the option of using gksu instead of sudo. Thanks for the help! smile


Board footer

Powered by FluxBB

Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.
Server: acrobat

Debian Logo