Joker
Joker

Reputation: 2239

Cannot open graphical application through command line?

I am having trouble opening graphical applications in linux (Sublime Text 2 in this case) through the terminal. I am using Fedora 17. I get this error for other graphical applications that I try to open up through the command line as well.

[root@computer djproject]# sublime settings.py
No protocol specified

(sublime:4202): Gtk-WARNING **: cannot open display: :0

Also, I get the same type of error when I try to do:

sudo sublime

Note in the command above I was logged in as a regular user without root access. Also 'sublime' is mapped to Sublime Text 2, and I have tested it before in other scenarios, so it is not the problem. Also, I have set this particular user up as a valid sudoer and the sudo command also works in other cases.

While researching the problem I came across many similar cases with no clear solution. The following link has a user with a similar problem (although using ssh and on Ubuntu, rather than local and Fedora in my case).

Thanks in advance!

Upvotes: 0

Views: 5095

Answers (4)

Armin Ghasemi
Armin Ghasemi

Reputation: 381

I know this is 5 years old post, but I spend much time to solve issue like this on installation of Renderman of Pixar. Then I like to send my solution that maybe helps someone else

The problem is because of this "sudoer (here root) has no access to graphical space". (I don't know it is always or sometimes. I faced this issue on Ubuntu 16.04)

Doing the following solved my issue:

first, start Terminal as graphical user, Alt+Ctrl+T then, execute these lines

$ unset XAUTHORITY
$ xhost add $DISPLAY . 123f
$ xhost +local:all
$ sudo xclock # or any graphical program needs sudoer 

Let me know your feedbacks

Upvotes: 0

I actually needed this (run an X application from CLI with a different user), and valid workarround is to SSH -X:

user1 owns X
user2 is the second user that wants to run an X program from CLI, in this example, eclipse ide

user1:~$ ssh -X user2@localhost
The authenticity of host 'localhost (127.0.0.1)' can't be established.
ECDSA key fingerprint is 
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'localhost' (ECDSA) to the list of known hosts.
user2@localhost's password: 
Welcome to Ubuntu 14.04.1 LTS (GNU/Linux 3.13.0-44-generic x86_64)

user2:~$ 
user2:~$ /opt/eclipse/eclipse

Upvotes: 0

jortony
jortony

Reputation: 7

I spent quite a lot of time trying to figure this problem out, and came across this thread as I found a fix. My problem was simply that I was running my commands from within the byobu session. I opened a new terminal tab and successfully ran the same commands.

Upvotes: 1

Jonny
Jonny

Reputation: 882

Since DISPLAY is being defined, this may be a problem with permissions. How are you starting X? (As far as I know normally X is started by root and when you login you are granted access such that these issues don't occur, unless you're running sudo from a different account than the one you're logged into X with.)

You need to provide the correct 'cookie' file to access the session (simply being root isn't enough to get in). For users this is normally ~/.Xauthority, so executing xauth merge /home/<user>/.Xauthority should do the trick.

Alternatively have you tried gksu?

Upvotes: 0

Related Questions