前言
这次使用VNC Viewer远程连接Ubuntu 14.04 系统之路并不顺畅。根据之前的博客,能够顺利连接上,但是连上之后发现没有菜单栏(menu)(有没有桌面我也忘了)。花了很久时间才解决,在此记录之。
几条原则
在此过程中,针对该类问题总结出了几条原则:
- 不要同时装几个桌面软件,在装新的之前,最好把前一个桌面软件卸载干净;
- 找对正确的参考文献很重要,找参考文献要:1)系统对的上,即都是Ubuntu 14.04,2)有操作过程截图的要靠谱一点;
- 学会看日志。
.vnc/
下面的log要多看,里面都记录了诸如报错之类的问题; - 不要打开太多网页,感觉有时候看的文献一多,反而迷失,在看了超过3个网页之后,如果还没有找到方案,还没有思路,这时候应该缓一缓,多思考,而不是一个劲的胡乱尝试(这是很危险的,容易越陷越深) (这个是general principle)
场景
我的VNC Viewer连接服务器上的Ubuntu 14.04 的过程是按照我之前的博客来的:
- 本地Windows远程连接阿里云服务器图形界面(使用vnc viewer) (主要参考)
- 详解:在windows上远程控制Ubuntu (次要参考)
- Windows上通过ssh和VNC Viewer分别连接本地Ubuntu(WSL)的终端和图形界面 (次要参考)
但是这次却和本地Windows远程连接阿里云服务器图形界面(使用vnc viewer) 里面显示的桌面不一样。没有菜单栏,中间甚至还有灰屏的情况。
解决方案第一步——清空过往package
由于我尝试了很多方法,安装了包括vncserver, vnc4server, tightvncserver, vino, gdm, LXDE, gnome, xfce4 等等等等package。。。
所以整个就乱套了。所以不得不清空一波。
具体的相关指令如下(仅供参考):
# find all vnc-related folder
sudo find / -iname "*vnc*" # No.1
# rm files
rm .xsession-errors
rm .Xauthority
rm .Xresources
rm /etc/alternatives/vncconfig
# rm xrdp
sudo dpkg -P xrdp
# purge packages about xfce4
sudo apt-get purge xfconf xfce4-utils xfwm4 xfce4-session xfdesktop4 exo-utils xfce4-panel xfce4-terminal thunar
sudo apt-get remove xfce4-*
sudo apt-get autoremove
# find vnc-related packages already installed
dpkg -l | grep vnc # No.2
dpkg -P remmina-plugin-vnc
dpkg -P libvncserver0
# find and rm server-related packages already installed
dpkg -l | grep server # No.3
dpkg -l | grep x-
sudo apt-get purge xserver-*
sudo dpkg -P x11-xfs-utils
sudo dpkg -P vino
sudo dpkg -P xinit
# reboot for refreshing (seems not necessary)
sudo reboot
# auto-remove vnc4server
sudo apt-get remove vnc4server # No.4
sudo apt-get remove --auto-remove vnc4server
sudo apt-get purge vnc4server
sudo apt-get purge --auto-remove vnc4server
# auto-remove other packages
sudo apt-get remove --auto-remove xvnc4viewer
sudo apt-get remove --auto-remove tightvncviewer
sudo apt-get remove --auto-remove vncviewer
sudo apt-get remove --auto-remove xinit
# find and rm server-related packages already installed
dpkg -l |grep desktop # No.5
grep installed /var/log/dpkg.log | grep xdg-utils # show installed time # No.6
sudo apt-get remove unity-*
sudo apt-get remove --auto-remove LXDE
sudo apt-get remove --auto-remove desktop-*
sudo apt-get remove --auto-remove gnome-panel
sudo apt-get remove --auto-remove gnome-settings-daemon
sudo apt-get remove --auto-remove metacity
sudo apt-get remove --auto-remove nautilus
sudo apt-get remove --auto-remove gnome-terminal
sudo apt-get remove --auto-remove ubuntu-desktop
sudo apt-get remove --auto-remove remmina-plugin-rdp
sudo apt-get remove --auto-remove lxmenu-data
# also rm
sudo dpkg -P desktop-base
P.S. 从 # No.1
到 # No.6
是几个关键的查找指令(已标注在上面代码中)。
运行完这些指令之后,我感觉基本就算清理的差不多了。
在此过程中参考了一些文献:
- How to remove tightvncserver from Ubuntu 14.04 (Trusty Tahr) (这个–auto-remove 很有用)
- How to completely uninstall applications by command line in Ubuntu 这个也很有用
- How To Uninstall vnc4server On Ubuntu 15.04 也很有用
- How to find out when Debian or Ubuntu package installed or updated 显示package 安装时间的,还可以。
- How to uninstall Real VNC in Ubuntu 14.04
- How do I remove XFCE from my computer?
- How do I remove vncserver?
解决方案第二部——重新配置vnc
主要参考:
(补充:How to install VNC server on ubuntu 14.04似乎更加详细,但是暂时没用上。)
期间稍作修改,具体如下:
1)安装Ubuntu-desktop
sudo apt-get install --no-install-recommends ubuntu-desktop gnome-panel gnome-settings-daemon metacity nautilus gnome-terminal gnome-core
2)安装vnc4server:
sudo apt-get install vnc4server
3)修改配置:
我没有修改:/usr/bin/vncserver
文件,而是直接vncserver,然后需要输入密码,然后会自动创建~/.vnc/
文件夹,包含xstartup
可执行文件,因此,我直接修改这个xstartup文件,删除其中原有内容,添加新内容如下:
#!/bin/sh
# Uncomment the following two lines for normal desktop:
# unset SESSION_MANAGER
# exec /etc/X11/xinit/xinitrc
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
#x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
#x-window-manager &
gnome-panel &
gnome-settings-daemon &
metacity &
nautilus &
gnome-terminal &
3.1)我还做了如下修改,运行:
sudo cp -rf .local .local-bk # original owner: root, and seems save some files for python3.6, and also some other files.
sudo chown -R apr:apr .local
不然的话,.vnc/下的log会提示permission的错误。
4)添加alias,nano ~/.bashrc
,在末尾添加如下行:
alias vkill='vncserver -kill :1'
alias vnc2='vncserver :1'
alias vnc='vncserver :1 -geometry 1920x1080'
然后 . ~/.bashrc
使其生效。(往后可以直接运行vkill
停止vnc进程,以及直接运行vnc
或者vnc2
来开启vnc,很方便)
5)运行 vnc
,然后得到界面如下(菜单栏已经出现):
至此,菜单栏已经出现。
TODO:打不开system setting
查看log显示:
(gnome-control-center.real:27532): Gdk-ERROR **: The program 'gnome-control-center.real' received an X Window System error.
This probably reflects a bug in the program.
The error was 'BadRequest (invalid request code or no such operation)'.
(Details: serial 136 error_code 1 request_code 149 (RANDR) minor_code 8)
(Note to programmers: normally, X errors are reported asynchronously;
that is, you will receive the error a while after causing it.
To debug your program, run it with the GDK_SYNCHRONIZE environment
variable to change this behavior. You can then get a meaningful
backtrace from your debugger if you break on the gdk_x_error() function.)
XIO: fatal IO error 11 (Resource temporarily unavailable) on X server ":1"
after 156 requests (154 known processed) with 0 events remaining.
大概知道解决方案在这个网页中:
I did a little test:
- upgraded to xorg 1.14
- switched from catalyst to xf86-video-ati drive
Most of the errors dissappeared (GOA still crashes).
But now i can only see message tray using keyboard shortcut (super + m). I read that I need to move my mouse fast to the botton edge of my screen - does not work - instead it show up randomly when i moved mouse near the bottom edge.
I don't want to use the open source drivers (slow and laggy with multi monitor setup I'm using). I hope gnome devs will fix this bugs soon.
SOLUTION (to still use catalyst):
I found out that this is an Xorg 1.12 bug.
Bug: http://lists.debian.org/debian-x/2012/12/msg00133.html
To solve this use patch from this bugreport to compile xorg 1.12
I used this aur packages:
1. https://aur.archlinux.org/packages/xf86-input-evdev1.12/
2. https://aur.archlinux.org/packages/xorg-server1.12/ - I have edited PKGBUILD to include patch from bug report above
PKGBUILD and patch:
https://gist.github.com/winglot/5450630
另外还有次要参考:Gdk-ERROR **: The program ‘_______’ received an X Window System error
但是我嫌麻烦,算了。以后有需要再说吧。
小结
最坑我的要数这个文献:Vnc Ubuntu 14.04 destop don’t show menus icon 这是造成我后续数个小时挣扎的起源。这里面是这样配置的~/.vnc/xstartup
的:
#!/bin/sh
unset SESSION_MANAGER
/etc/X11/xinint/
xrdb $HOME/.Xresources
xsetroot -solid grey
#x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
x-window-manager &
# Fix to make GNOME work
export XKL_XMODMAP_DISABLE=1
#/etc/X11/Xsession
gnome-session --session=gnome-fallback &
里面的:/etc/X11/xinint/
是个错别字,xinint
应该改为xinit
。而且就算改了,从.vnc/ 下的log以及连接的界面来看发现也还是有问题,总之问题多多,后面就陆续参考了其他文献,都失败了。这里简要列举一部分文献:
- 怎么卸载ubuntu 14.04 的 xubuntu桌面
- vnc4server: Normal desktop permission prob with xinitrc
- Ubuntu Server VNC Server - Gray Screen
- TightVNC
- vnc grey screen (16.04, tightvnc, xfce4) : SOLVED
- [SOLVED] TightVNC just gives a gray screen with an X cursor
- tightvncserver on Xubuntu gives gray screen when logged in
- VNC
- How to properly configure xstartup file for TightVNC with Ubuntu VPS GNOME environment
- Vncserver with Google cloud instance
- VNC Performance issue #93
- Solid gray screen with x-cursor when trying to VNC connect to raspberry pi 3
- vncserver remote session grey screen ubuntu 16.04
- “CRITICAL: We failed, but the fail whale is dead. Sorry…”
- vncserver grey screen ubuntu 16.04 LTS
- VNC server not showing icons in Ubuntu 18.04
- TIghtVNC stopped working. Grey screen with X cursor…
- gray screen when i startx
- VNC viewer grey screen since upgrade to Ubuntu 14.04 from Ubuntu 12
- Default Ubuntu Desktop with TightVnc and Windows Linux Subsystem
- Started tightvncserver on Ubuntu, but viewer complains about missing .xsession file
- How to make VNC Server work with ubuntu-desktop without xfce
- vnc grey screen (16.04, tightvnc, xfce4) : SOLVED
- Couldn’t start Xtightvnc trying default font path - VNCServer