Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

The command works with the user "heo". But I get the error by "$ su another_user; cat file | xclip":

No protocol specified Error: Can't open display: :0.0

A superuser has black CLI, no error message or text, with the xauth-command.

  1. How can I keep the same display with many users?

  2. How can I change the display to :0 or :1 for all users?

  3. Why is the xauth-command black with one superuser?

share|improve this question
    
And now, I've updated the answer. –  derobert Aug 23 '09 at 9:35
add comment

1 Answer

up vote 5 down vote accepted

xclip can't talk to your X server. Check that $DISPLAY is set correctly. Do other X clients work with the same $DISPLAY setting?

This:

$ echo 'hello' | xclip

works just fine for me.

edit

You get the error after su'ing to another user because that user doesn't have appropriate permissions to connect to your X server. X uses a permission checking protocol known as MIT magic cookie, which works by creating a random string to use as a password. That password is stored in the file $XAUTHORITY, or ~/.Xauthority if the environment variable is not set. It is manipulated by the xauth tool. For example,

$ xauth list
…
Feynman/unix:0  MIT-MAGIC-COOKIE-1  <<redacted>>
…

I'm not sure what you're doing the su for, but:

  • if it's so you can read the file, then just run the cat as the other user, and pipe the output of su to xclip. This way, xclip runs as your user, and works.
  • if you're trying to set the clipboard for another user's X session, then you'll need to set $DISPLAY to that user's display, and $XAUTHORITY to that user's X authority file. Look into ConsoleKit (if you're using it) and /var/lib/gdm (if you're using gdm) to find said things.

If none of the above, then you'll have to use xauth to set up the authorization, and keep in mind that anything connecting to your X server can do all sorts of evil, such as watch all your keystrokes.

PS: The $DISPLAY refers to which X server they're logged in to. Unless you've set up multiple servers running (so multiple users may log in at once), it will be the same for all users.

share|improve this answer
    
When you pull up a terminal, and run xauth list, what error messages do you get? –  derobert Aug 27 '09 at 13:42
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.