1

Yesterday I had the same issue, I solved it by running

sudo synaptic

But today I don't know what's happening, if I run gksu synaptic or gksudo synaptic they don't do anything.

If I go to root and execute these commands or execute sudo synaptic, I see:

sudo synaptic
No protocol specified

(synaptic:32377): Gtk-WARNING **: cannot open display: :0.0

EDIT: @Nunoxic

I'm working on my local computer. When I do sudo apt-get update some stuff will be updated and some some stuff will not be updated

E: Some index files failed to download. They have been ignored, or old ones used instead.

I ran sudo apt-get update 2 days ago. when i do echo $DISPLAY the output is :0

@Gilles

the output of echo $XAUTHORITY is nothing at all:)

the output of sudo env | sort is

COLORTERM=gnome-terminal
DISPLAY=:0.0
HOME=/root
LANG=en_US.UTF-8
LANGUAGE=en_US:en
LC_COLLATE=en_US.UTF-8
LC_CTYPE=en_US.UTF-8
LC_MESSAGES=en_US.UTF-8
LOGNAME=root
MAIL=/var/mail/root
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin
SHELL=/bin/bash
SUDO_COMMAND=/usr/bin/env
SUDO_GID=0
SUDO_UID=0
SUDO_USER=root
TERM=xterm
USERNAME=root
USER=root

the output of sudo xterm is

No protocol specified
Warning: This program is an suid-root program or is being run by the root user.
The full text of the error or warning message cannot be safely formatted
in this environment. You may get a more descriptive message by running the
program as a non-root user or by removing the suid bit on the executable.
xterm Xt error: Can't open display: %s

EDIT

the output of XAUTHORITY=~/.Xauthority; sudo xterm is

No protocol specified
Warning: This program is an suid-root program or is being run by the root user.
The full text of the error or warning message cannot be safely formatted
in this environment. You may get a more descriptive message by running the
program as a non-root user or by removing the suid bit on the executable.
xterm Xt error: Can't open display: %s

the output of sudo -s9999 strace xterm is

sudo: invalid option -- '9'
usage: sudo -h | -K | -k | -L | -V
usage: sudo -v [-AknS] [-g groupname|#gid] [-p prompt] [-u user name|#uid]
usage: sudo -l[l] [-AknS] [-g groupname|#gid] [-p prompt] [-U user name] [-u
            user name|#uid] [-g groupname|#gid] [command]
usage: sudo [-AbEHknPS] [-C fd] [-g groupname|#gid] [-p prompt] [-u user
            name|#uid] [-g groupname|#gid] [VAR=value] [-i|-s] [<command>]
usage: sudo -e [-AknS] [-C fd] [-g groupname|#gid] [-p prompt] [-u user
            name|#uid] file ...
Lynob
  • 4,204
  • Try typing echo $DISPLAY in the terminal and paste the output. Also, are you working on your computer locally or through SSH? Thirdly, what happens if you open the terminal and type something like sudo apt-get update –  Feb 14 '12 at 10:36
  • @Nunoxic Please read my edit – Lynob Feb 14 '12 at 12:02
  • I'm not sure if it will help but try the following : sudo apt-get clean cd /var/lib/apt sudo mv lists lists.old sudo mkdir -p lists/partial sudo apt-get clean sudo apt-get update –  Feb 14 '12 at 12:10
  • @Nunoxic when i do sudo apt-get clean cd /var/lib/apt sudo mv lists lists.old sudo mkdir -p lists/partial sudo apt-get clean sudo apt-get update I see E: Command line option 'p' [from -p] is not known. – Lynob Feb 14 '12 at 12:17
  • That's rather funny. Try --parents instead. If that doesn't work as well try breaking that command down to mkdir lists and cd lists and finally, mkdir partial topped with cd .. –  Feb 14 '12 at 12:44
  • Also, please try running the commands separately instead of pasting directly from above. –  Feb 14 '12 at 12:57
  • @Nunoxic did that, didn't fix it :( – Lynob Feb 14 '12 at 14:36
  • Please show the output of echo $XAUTHORITY, sudo env | sort, and sudo xterm. – Gilles 'SO- stop being evil' Feb 14 '12 at 22:22
  • @Gilles please read my edit – Lynob Feb 16 '12 at 09:27
  • Let's pull up some heavier artillery. Please post the trace of sudo -s9999 strace xterm (it'll be huge, put it up on http://pastebin.com/ or similar if it doesn't fit in your question). Note that the trace will contain X cookies, which could give someone access to your computer in unusual circumstances; if people other than you have access to your computer, restart your X server(s) after posting (if not, you're fine). – Gilles 'SO- stop being evil' Feb 16 '12 at 23:04
  • @Gilles please read my edit and thank you for your time sir, i really appreciate it :) – Lynob Feb 16 '12 at 23:11
  • Oops, sorry, typo: I meant sudo strace -s9999 xterm. – Gilles 'SO- stop being evil' Feb 17 '12 at 00:40
  • @Gilles please see this http://pastebin.com/2v1p577c and this http://pastebin.com/vcsA2GyX – Lynob Feb 17 '12 at 10:37
  • In the output of sudo strace -s9999 xterm, I see that xterm is attempting a TCP connection to the X server (and failing, which is expected). With DISPLAY=:0.0, xterm should be making a local connection, through /tmp/.X11-unix/X0. Hmmm, broken permissions, maybe? What is the output of ls -ld /tmp /tmp/.X11-unix /tmp/.X11-unix/X0? – Gilles 'SO- stop being evil' Feb 20 '12 at 18:47
  • @Gilles I don't because Saturday, I uninstalled and reinstalled mint 12:) that's how i fixed everything lol :D – Lynob Feb 20 '12 at 19:04

1 Answers1

1

One possible explanation is that due to some recent change the location of the X cookie file has changed from ~/.Xauthority to some location indicated by $XAUTHORITY. The X cookie file contains a password that X applications must provide when connected to the X server. (See the first part of this answer for more background.)

Make sure that the XAUTHORITY variable is not erased by sudo. Run visudo to add this line to the sudoers file:

Defaults env_keep += XAUTHORITY

A related possibility is that if you don't have XAUTHORITY in your environment, the X cookie is stored in ~/.Xauthority. If the HOME environment variable is not preserved by sudo, then the X applications running under sudo will look in ~root/.Xauthority which doesn't have the right cookie. There are three easy ways to solve this, from most convenient to less convenient:

  • Turn off the env_reset option in sudoers (when you can run arbitrary commands as the target user, there is no real security benefit to env_reset), and don't turn on set_home. This way, ~/.Xauthority under sudo still refers to the calling user's home directory.
  • Tell sudo to preserve the XAUTHORITY variable as above, and set XAUTHORITY in your X session startup file, even if it's the default value.
  • Set XAUTHORITY using the home directory of the calling user inside the sudo session, e.g. by running

    sudo env XAUTHORITY=${XAUTHORITY:-~/.Xauthority} xterm
    
  • I added Defaults env_keep += XAUTHORITY to sudoers now what? the error is still there – Lynob Feb 14 '12 at 16:31
  • @SomeoneLikeYou Given your environment under sudo, this could be a different problem locating the X cookie, see my edit. – Gilles 'SO- stop being evil' Feb 16 '12 at 19:46
  • sudo env XAUTHORITY=${XAUTHORITY:-~/.Xauthority} xterm gives me No protocol specified Warning: This program is an suid-root program or is being run by the root user. The full text of the error or warning message cannot be safely formatted in this environment. You may get a more descriptive message by running the program as a non-root user or by removing the suid bit on the executable. xterm Xt error: Can't open display: %s So how to do the other 2 options sir? I'm not a linux expert :) – Lynob Feb 16 '12 at 21:48
  • @SomeoneLikeYou What happens if you run export XAUTHORITY=~/.Xauthority; sudo xterm? You may have a different, rarer problem than what I initially suspected. – Gilles 'SO- stop being evil' Feb 16 '12 at 23:00
  • you are the most helpful guy on this forum, i re-installed mint coz i had many problems :) – Lynob Feb 20 '12 at 18:13