ubuntu 14.04 配置VNC server

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

参考:http://blog.csdn.net/vbskj/article/details/52129757

http://blog.csdn.net/vbskj/article/details/52129757


VNC server的安装不用多说。但问题是,安装完成后,只能看到terminal,看不到桌面与菜单。原因是VNC默认是不启动桌面环境的。
虽然linuxer们坚持认为一个terminal就够了,但这不是我的菜,还是要搞出桌面才够爽。
vnc server启动时,会调用“~/.vnc/xstartup”进行初始化,我们的任务就是在这里启动桌面环境。
ubuntu支持两种桌面环境:unity与gnome,(unity是对gnome的一种深度定制)
还写以选择安装一种轻量级桌面环境,xfce4。

原来计划搞定三种桌面环境,最终却没搞定ubuntu 14.04上默认支持的unity :(
不管怎么,三种方式都放到下面的脚本中了,unity仅作参考了。

安装gnome环境相关,sudo apt-get install ubuntu-desktopgnome-panel gnome-settings-daemon Metacity nautilus gnome-terminal


点击(此处)折叠或打开

  1. #!/bin/sh

  2. # DESK_TYPE=xfce
  3. DESK_TYPE=gnome
  4. # DESK_TYPE=unity

  5. # Uncomment the following two lines for normal desktop:
  6. unset SESSION_MANAGER
  7. unset DBUS_SESSION_BUS_ADDRESS
  8. # exec /etc/X11/xinit/xinitrc

  9. [ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
  10. [ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
  11. xsetroot -solid grey
  12. vncconfig -iconic &
  13. # x-terminal-emulator -geometry 80x24+10+10 -ls -title"$VNCDESKTOP Desktop"&
  14. # x-window-manager &

  15. echo $DESK_TYPE
  16. # xfce desktop
  17. if test $DESK_TYPE = xfce; then
  18. x-terminal-emulator -geometry 80x24"$VNCDESKTOP Desktop"&
  19. x-session=-manager &
  20. xfdesktop & xfce4-panel &
  21. xfce4-menu-plugin &
  22. xfsettingsd &
  23. xfconfd i&
  24. xfwm4&
  25. fi

  26. # gnome desktop
  27. if test $DESK_TYPE = gnome; then
  28. gnome-session &
  29. gnome-panel &
  30. gnome-settings-daemon &
  31. Metacity &
  32. nautilus -n &
  33. gnome-terminal &
  34. /usr/bin/gsettings set org.gnome.desktop.wm.keybindings panel-main-menu"['F1']"
  35. /usr/bin/gsettings set org.gnome.desktop.wm.keybindings maximize"['KP_5']"
  36. /usr/bin/gsettings set org.gnome.desktop.wm.keybindings unmaximize"['F5']"
  37. /usr/bin/gsettings set org.gnome.desktop.wm.keybindings show-desktop"['d']"
  38. /usr/bin/gsettings set org.gnome.desktop.wm.keybindings switch-applications"['Tab']"
  39. /usr/bin/gsettings set org.gnome.desktop.wm.keybindings switch-group"['Above_Tab']"
  40. /usr/bin/gsettings set org.gnome.desktop.wm.keybindings switch-input-source"[]"
  41. /usr/bin/gsettings set org.gnome.desktop.wm.keybindings switch-input-source-backward"[]"
  42. /usr/bin/gsettings set org.gnome.settings-daemon.plugins.media-keys terminal"['t']"
  43. fi

  44. # unity desktop
  45. if test $DESK_TYPE = unity; then
  46. export DESKTOP_SESSION=ubuntu
  47. export GDMSESSION=ubuntu
  48. export STARTUP="/usr/bin/gnome-session --session=ubuntu"
  49. $STARTUP &
  50. fi

vnc配置好后,如果希望开机启动,可以建立文件“/etc/vncserver/vncservers.conf”用来配置需要启动的server

点击(此处)折叠或打开

VNCSERVERS="1:hao-64 11:hao-64 12:hao-64 13:hao-64 14:hao-64 15:hao-64"
  • VNCSERVERARGS[1]="-geometry 1024x768"
  • VNCSERVERARGS[11]="-geometry 1680x1050"
  • VNCSERVERARGS[12]="-geometry 1366x768"
  • VNCSERVERARGS[13]="-geometry 1280x1024"
  • VNCSERVERARGS[14]="-geometry 1024x768"
  • VNCSERVERARGS[15]="-geometry 800x600"
  • 再建立文件“/etc/init.d/vncserver”,用于开机启动配置文件

    点击(此处)折叠或打开

    #!/bin/bash

  • unset VNCSERVERARGS
  • VNCSERVERS=""
  • [-f/etc/vncserver/vncservers.conf]&..conf
  • prog=$"VNC server"
  • start(){
  • /lib/lsb/init-functions
  • REQ_USER$2
  • echo-n $"Starting $prog: "
  • ulimit-S-c 0>/dev/null 2&1
  • RETVAL=0
  • fordisplayin${VNCSERVERS}
  • do
  • export USER"${display##*:}"
  • iftest-z"${REQ_USER}"-o=${USER}; then
  • echo-n"${display} "
  • unset BASH_ENV ENV
  • DISP"${display%%:*}"
  • export VNCUSERARGS"${VNCSERVERARGS[${DISP}]}"
  • su $}-c"cd ~${USER} && [ -f .vnc/passwd ] && vncserver :${DISP} ${VNCUSERARGS}"
  • fi
  • done
  • }
  • stop"Shutting down VNCServer: "
  • "${display} "
  • unset BASH_ENV ENV
  • export USER"${display##*:}"
  • su $"vncserver -kill :${display%%:*}"&1
  • fi
  • done
  • echo-e"\n"
  • echo"VNCServer Stopped"
  • }
  • case"$1"in
  • start)
  • start $@
  • ;;
  • stop)
  • stop $@
  • ;;
  • restart|reload)
  • stop $@
  • sleep 3
  • start $@
  • ;;
  • condrestart)
  • if/var/lock/subsys;then
  • stop $@
  • sleep 3
  • start $@
  • fi
  • ;;
  • status)
  • status Xvnc
  • ;;
  • *)
  • echo $"Usage: $0 {start|stop|restart|condrestart|status}"
  • exit 1
  • esac
  • 调用命令“ update-rc.d vncserver defaults 99 ”刷新启动配置。
    最后,重启系统 原文链接:https://www.f2er.com/ubuntu/355661.html

    猜你在找的Ubuntu相关文章