Ubuntu|Ubuntu 16.04 配置VNCSERVER

#!/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/.Xresourcesxsetroot -solid grey vncconfig -iconic &x-terminal-emulator -geometry 80x24+10+10 -ls -title"$VNCDESKTOPDesktop"&x-window-manager &gnome-panel &gnome-settings-daemon &metacity &nautilus &首先安装:

sudo apt install xfce4 xfce4-goodies tightvncserver
【Ubuntu|Ubuntu 16.04 配置VNCSERVER】sudo apt-get install vnc4server
安装之后,执行:
vnc4server
输入密码并确认,
此时,~/.vnc/下生成xstartup文件。
备份startup文件:
mv ~/.vnc/xstartup ~/.vnc/xstartup.bak
执行:
vncserver -kill :1

杀掉刚刚开启的进程,其中1对应执行vnc4server那步创建时的进程。
届时,修改xstartup
vim ~/.vnc/xstartup
内容如下:
#!/bin/bash

xrdb $HOME/.Xresources
startxfce4 &
修改xstartup的权限:
chmod +x ~/.vnc/xstartup
配置完成,启动vncserver:
vncserver
附1:Unity风格
安装包:
sudo apt-get install --no-install-recommends ubuntu-desktop gnome-panel gnome-settings-daemon metacity nautilus gnome-terminal
sudo apt-get install vnc4server

对应的xstartup文件:
[-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"$VNCDESKTOPDesktop"&

x-window-manager &

gnome-panel &

gnome-settings-daemon &

metacity &

nautilus &

附2随开机启动VNCSERVER:
sudo vim /etc/systemd/system/vncserver@.service

新建如下内容:
[Unit]
Description=Start TightVNC server at startup
After=syslog.target network.target
[Service]
Type=forking
User=yourusername
PAMName=loginPIDFile=/home/yourusername/.vnc/%H:%i.pid
ExecStartPre=-/usr/bin/vncserver -kill :%i > /dev/null 2>&1
ExecStart=/usr/bin/vncserver -depth 24 -geometry 1280x800 :%i
ExecStop=/usr/bin/vncserver -kill :%i[Install]WantedBy=multi-user.target

执行:
sudo systemctl daemon-reload
sudo systemctl enable vncserver@1.service
如果vncserver在运行,停止运行它。
sudo systemctl start vncserver@1
sudo systemctl status vncserver@1

    推荐阅读