Ubuntu14.04配置VNC服务

前端之家收集整理的这篇文章主要介绍了Ubuntu14.04配置VNC服务前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

第一步:安装VNCserver

指令:sudo apt-get install vnc4server

第二步:开启vnc服务

指令:vncserver

这里需要输入vnc链接的密码

看到..desk is master:1 说明已经启动了vnc服务。启动vnc成功后,会在主目录下产生一个.vnc目录(~/.vnc/)。 这时候window通过vnc链接到linux时,桌面系统是doc。

第三步:修改~/.vnc/xstartup文件

文件是配置vnc桌面系统类型。默认内容如下。

#!/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 &

我们需要将最后一行“x-window-manager &”改为我们自己的Ubuntu图形界面服务,那么改成什么呢?这就要看你Ubuntu是什么桌面环境了,Ubuntu有gnome、KDE、Unity等桌面环境。

查看ubuntu桌面环境指令:vim/usr/share/gnome-session/sessions/ubutu.session

如果是gnome桌面,最后一行改成gnome-session &;
如果是KDE桌面,最后一行改成startkde &;
如果是Unity桌面,桌面session的名称是ubuntu-2d,则将最后一行改为:
export STARTUP="/usr/bin/gnome-session --session=ubuntu-2d"
$STARTUP

第四步:如果原始linux系统没有配置桌面系统

(1)安装x-windows的基础
sudo apt-get install x-window-system-core(一般都已安装)
(2)安装登录管理器
sudo apt-get install gdm (还可以为kdm/xdm)
(3)安装Ubuntu的桌面
sudo apt-get install ubuntu-desktop

第五步:完美配置

修改vim ~/.vnc/xstartup中的内容如下
#!/bin/sh

# DESK_TYPE=xfce
DESK_TYPE=gnome
# DESK_TYPE=unity

# 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 &

echo $DESK_TYPE
# xfce desktop
if test $DESK_TYPE = xfce; then
x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
x-session=-manager &
xfdesktop & xfce4-panel &
xfce4-menu-plugin & 
xfsettingsd &
xfconfd i&
xfwm4&
fi

# gnome desktop
if test $DESK_TYPE = gnome; then
gnome-session &
gnome-panel &
gnome-settings-daemon &
Metacity &
nautilus -n &
gnome-terminal &
/usr/bin/gsettings set org.gnome.desktop.wm.keybindings panel-main-menu "['F1']"
/usr/bin/gsettings set org.gnome.desktop.wm.keybindings maximize "['KP_5']"
/usr/bin/gsettings set org.gnome.desktop.wm.keybindings unmaximize "['F5']"
/usr/bin/gsettings set org.gnome.desktop.wm.keybindings show-desktop "['d']"
/usr/bin/gsettings set org.gnome.desktop.wm.keybindings switch-applications "['Tab']"
/usr/bin/gsettings set org.gnome.desktop.wm.keybindings switch-group "['Above_Tab']"
/usr/bin/gsettings set org.gnome.desktop.wm.keybindings switch-input-source "[]"
/usr/bin/gsettings set org.gnome.desktop.wm.keybindings switch-input-source-backward "[]"
/usr/bin/gsettings set org.gnome.settings-daemon.plugins.media-keys terminal "['t']"
fi

# unity desktop
if test $DESK_TYPE = unity; then
export DESKTOP_SESSION=ubuntu
export GDMSESSION=ubuntu
export STARTUP="/usr/bin/gnome-session --session=ubuntu"
$STARTUP &
fi

猜你在找的Ubuntu相关文章