$ sudo apt-get install vnc4serverubuntu
安裝完之後在終端下輸入:$ vncserverwindows
首次輸入vncserver會提示輸入vnc登錄密碼,設置完成以後,產生以下信息:$ gedit ~/.vnc/xstartup服務器
默認配置文件~/.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 &session
#!/bin/sh
# Uncomment the following two lines for normal desktop:
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
# 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 &
export DESKTOP_SESSION=ubuntu-2d
#這個 ubuntu-2d 參考 /usr/share/gnome-session/sessions/ 下的文件名設置成不一樣的值
export GDMSESSION=ubuntu-2d
export STARTUP="/usr/bin/gnome-session --session=ubuntu-2d"
$STARTUP app
$ vncserver -kill :1ssh
PS:注意這裏-kill以後須要加空格,本人就是由於漏了空格不只沒有可以成功關閉端口1的vncserver,反而又啓動了一個新的vncserver端口$ vncserver測試
此時vncserver會再次打開端口1,而後遠程電腦就可使用vnc客戶端進行鏈接了,windows下可使用realvnc公司的vncviewer,Ubuntu下若是以前沒有安裝過vncserver的話能夠只安裝vnc客戶端,在終端下輸入:$ sudo apt-get install xvnc4viewer ui
安裝完成以後,若是在本機測試的話輸入:$ vncviewer localhost:1spa
這裏localhost對應本機的ip地址,若是是遠程登錄的話將localhost改成要登錄主機的ip地址便可,鏈接上之後會提示輸入密碼,輸入會出現遠程桌面。$ vncserver :xxx
這裏的xxx對應你想要開啓的服務端口號。$ sudo apt-get install xfce4
相應的xstartup文件配置以下:
#!/bin/shvnc鏈接上以後遠程桌面以下:
# Uncomment the following two lines for normal desktop:
# unset SESSION_MANAGER
# unset DBUS_SESSION_BUS_ADDRESS
#上面這句話若是在xubuntu桌面環境下開啓vnc的話最好取消註釋
# 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 &
x-session-manager &
xfdesktop & xfce4-panel &
xfce4-menu-plugin &
xfsettingsd &
xfconfd &
xfwm4 &