However, "E233: cannot open display" error appears when starting gvim
on ubuntu 8.04 root shell.
# gvim /etc/fstab
E233: cannot open display
Press ENTER or type command to continue
# kdesudo gvim /etc/fstab
kdesudo: cannot connect to X server
What does 'DISPLAY' say, before and after you run the sudo?
# echo $DISPLAY
# sudo echo $DISPLAY
That's now X works.
To use X from another user, such as root, the DISPLAY environment variable
must be set and the X server TOLD to allow it.
Try this...
xhost + localhost
sudo DISPLAY=localhost:0.0
sudo gvim
--
| spi...@freenet.co,uk | "Are you pondering what I'm pondering Pinky?" |
| Andrew Halliwell BSc | |
| in | "I think so brain, but this time, you control |
| Computer Science | the Encounter suit, and I'll do the voice..." |
I strongly, strongly recommend against using xhost this way. xhost is
a very powerful, and very dangerous command, that can allow massive
access to unauthorized people to your X session, for stealing
keystrokes and windows with root access and other
I regularly use 'sudo command arguments' from an X session as a non-
root user, allowing root to pop open a window using the already
available 'DISPLAY' settings. I assume kdesudo does the same thing
properly?
If the machine is single user, such as mine, there's no harm in opening
xhost to localhost. But yes, if it's a shared machine with multiple users
and sessions, it's not THAT good an idea.
> I regularly use 'sudo command arguments' from an X session as a non-
> root user, allowing root to pop open a window using the already
> available 'DISPLAY' settings. I assume kdesudo does the same thing
> properly?
There's also sux on some distros (if you don't have kde installed).
--
| |What to do if you find yourself stuck in a crack|
| spi...@freenet.co.uk |in the ground beneath a giant boulder, which you|
| |can't move, with no hope of rescue. |
| Andrew Halliwell BSc |Consider how lucky you are that life has been |
| in |good to you so far... |
| Computer Science | -The BOOK, Hitch-hiker's guide to the galaxy.|
# xhost + localhost
xhost: unable to open display "localhost:0.0"
# DISPLAY=:0.0
# xclock
Invalid MIT-MAGIC-COOKIE-1 keyError: Can't open display: :0.0
# DISPLAY=:0
# xclock
Invalid MIT-MAGIC-COOKIE-1 keyError: Can't open display: :0
On Aug 30, 5:11 pm, Andrew Halliwell <spi...@ponder.sky.com> wrote:
> TsanChung <tsanchung.w...@gmail.com> wrote:
> > "sudo gvim" is ok on a non-root shell.
> > $ sudo gvim /etc/fstab
> > [sudo] password for ts:
>
> > However, "E233:cannotopendisplay" error appears when starting gvim
> > on ubuntu 8.04 root shell.
> > # gvim /etc/fstab
> >E233:cannotopendisplay
> > Press ENTER or type command to continue
> > # kdesudo gvim /etc/fstab
> > kdesudo:cannotconnect to X server
>
> That's now X works.
> To use X from another user, such as root, theDISPLAYenvironment variable
> must be set and the X server TOLD to allow it.
>
> Try this...
> xhost + localhost
> sudoDISPLAY=localhost:0.0
You'll get that error if /etc/hosts defines only 127.0.0.1 as localhost,
but you're connected over IPv6. Edit /etc/hosts so that BOTH 127.0.0.1
and ::1 are defined as localhost.
Since you're apparently connected via ssh, you really shouldn't have to
mess with xhost. In fact, messing with xhost is usually very bad for
security. Just connect with the -X switch, which you're probably
already doing.
I followed your instructions to edit /etc/hosts as follows but the
problem still exists.
127.0.0.1 localhost
::1 localhost
127.0.1.1 tc-desktop
# The following lines are desirable for IPv6 capable hosts
#::1 ip6-localhost ip6-loopback
...
I am using gvim on the root shell of Konsole on ubuntu 8.04, I am not
using ssh. I experiment with xhost because I want to solve the
"cannot open display" problem.
Sorry. I missed your mention of Konsole the first time. I got
distracted by DISPLAY=localhost:0.0.
So now I'm wondering why you set DISPLAY. It should have already been
:0.0 (i.e., no localhost hostname), which is the correct value for
someone at the console.
If you just open a terminal window and "echo $DISPLAY" then what do you
get? If you don't set DISPLAY first, does xclock or gvim give an error
then? They should just work without changing DISPLAY.
I use Konsole 1.6.6 on KDE 3.5.10 & kubuntu 8.04.
The regular (non-root) console on Konsole is ok:
$ echo $DISPLAY
:0
$ xclock
The root console on Konsole cannot start xclock:
# echo $DISPLAY