Ubuntu 16.04下安装VNC和Unity桌面系统

感谢微魔大佬的大力滋磁,原文链接:https://www.vmvps.com/installing-vnc-and-unity-desktop-system-under-ubuntu-16-04-on-vps.html

Ubuntu 16.04下安装VNC和Unity桌面系统

0.更新系统
sudo apt-get update && sudo apt-get upgrade
1.安装桌面套件
sudo apt-get install --no-install-recommends ubuntu-desktop gnome-panel gnome-settings-daemon metacity nautilus gnome-terminal firefox
sudo apt-get install vnc4server
2.开启vncserver,会提示输入密码(最长8位)
vncserver :1

这时候如果你连接会发现是一片灰色,需要修改一下视窗系统的启动文件

3.关闭vncserver
vncserver -kill :1
4.修改~/.vnc/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 &


5.开启vncserver

vncserver :1

连接vnc的方法:

6.使用VNC Viewer(强烈建议去官方下载),连接地址为ip:5901

7.开启VNCServer的自启动,运行crontab -e,加入如下命令,以后重启就会自动运行vncserver了

@reboot /usr/bin/vncserver :1