如何在Ubuntu中安装和配置vncserver
时间:2019-08-20 17:58:15 来源:igfitidea点击:
如果我们只是在Ubuntu中安装vnc server而不修改xstartup文件,
那么在远程vnc访问中,它将不会显示桌面菜单。
在本教程中,我们将学习如何在Ubuntu中安装和配置vncserver,以及远程访问桌面菜单。
教程是在ubuntu12.04和12.10中完成的。
安装tightvncserver包
sudo apt-get install tightvncserver
设置密码
安装完成后,运行 vncpasswd命令设置VNC服务器的密码。
当询问Would you like to enter a view-only password
时,一定要选择n
Hyman@mypc:~$ vncpasswd Using password file /home/sapplican/.vnc/passwd Password: Verify: Would you like to enter a view-only password (y/n)? n Hyman@mypc:~$
备份xstartup文件
进行备份是一个良好的习惯
Hyman@mypc:~/.vnc$ cd ~/.vnc Hyman@mypc:~/.vnc$cp -p xstartup xstartup.orig Hyman@mypc:~/.vnc$> xstartup
编辑xstartup文件
添加以下内容:
Hyman@mypc:~/.vnc$ vi xstartup #!/bin/sh # Change "GNOME" to "KDE" for a KDE desktop, or "" for a generic desktop MODE="GNOME" #Uncommment this line if using Gnome and your keyboard mappings are incorrect. #export XKL_XMODMAP_DISABLE=1 # Load X resources (if any) if [ -e "$HOME/.Xresources" ] then xrdb "$HOME/.Xresources" fi # Try a GNOME session, or fall back to KDE if [ "GNOME" = "$MODE" ] then if which gnome-session >/dev/null then gnome-session –session=ubuntu-2d & else MODE="KDE" fi fi # Try a KDE session, or fall back to generic if [ "KDE" = "$MODE" ] then if which startkde >/dev/null then startkde & else MODE="" fi fi # Run a generic session if [ -z "$MODE" ] then xsetroot -solid "#DAB082" x-terminal-emulator -geometry "80×24+10+10" -ls -title "$VNCDESKTOP Desktop" & x-window-manager & fi Save and exit by pressing key , esc :wq enter
使用以下命令运行vncserver
Hyman@mypc:~/.vnc$ vncserver New ‘X’ desktop is mypc:1 Creating default startup script /home/Hyman/.vnc/xstartup Starting applications specified in /home/Hyman/.vnc/xstartup Log file is /home/Hyman/.vnc/mypc:1.log Hyman@mypc:~/.vnc$ Note : mypc:1 states that from remote access you have to use DISPLAY :1 and here mypc is my machine host name
在远程PC机使用vnc客户端访问VNC服务器
在Linux中,使用的是vncviewer。
vncviewer ipaddress-of-server:1
终止vncserver进程
vncserver -kill :DISPLAY_Number 比如: vncserver -kill :1