转载于http://blog.chinaunix.net/uid-10435474-id-3267834.html
System->Administration->Add/Remove Software 安装VNC,然后System->Administration->Services启动服务
默认情况下,Red Hat Enterprise Linux安装程序会将VNC服务安装在系统上。
vnc-server-4.1.2-9.el5
[root@localhost ~]#
2、[root@localhost ~]# service vncserver start 第一次启动时会提示输入密码,这个密码是客户端登录这个VNC服务器时需要提供的验证密码。
. .cshrc .gnome2 .metacity .vnc
.. Desktop .gnome2_private .mozilla .Xauthority
anaconda-ks.cfg .dmrc .gstreamer-0.10 .nautilus .xsession-errors
.bash_history .eggcups .gtkrc-1.2-gnome2 .redhat
.bash_logout .gconf .ICEauthority .tcshrc
.bash_profile .gconfd install.log .Trash
.bashrc .gnome install.log.syslog .twmjtHtnR
[root@localhost ~]#
[root@localhost .vnc]# ls
localhost.localdomain:1.log localhost.localdomain:1.pid passwd xstartup
[root@localhost .vnc]#
因为服务是第一次执行,需要输入密码,这个密码被加密保存在用户主目录下的.vnc子目录(/root/.vnc/passwd)中;同时在用户主目录下的.vnc子目录中为用户自动建立xstartup配置文件(/root/.vnc/xstartup),在每次启动VND服务时,都会读取该文件中的配置信息。:/root/.vnc/目录下还有一个“testdb:1.pid”文件,这个文件记录着启动VNC后对应后天操作系统的进程号,用于停止VNC服务时准确定位进程号。
桌面号为“1” ---- 端口号为5901
桌面号为“2” ---- 端口号为5902
桌面号为“3” ---- 端口号为5903
……
基于Java的VNC客户程序Web服务TCP端口从5800开始,也是与桌面号相关,对应关系如下
桌面号为“1” ---- 端口号为5801
桌面号为“2” ---- 端口号为5802
桌面号为“3” ---- 端口号为5803
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
xterm -geometry 80x24 10 10 -ls -title "$VNCDESKTOP Desktop" &
twm &
[root@testdb ~]# vncserver :1
vnc-server-4.1.2-9.el5
[root@localhost ~]# vncserver :1
Verify: 这个密码可以通过vncpasswd来修改
xauth: creating new authority file /root/.Xauthority
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/localhost.localdomain:1.log
. .bashrc .gconfd .ICEauthority .tcshrc
.. .cshrc .gnome install.log .Trash
anaconda-ks.cfg Desktop .gnome2 install.log.syslog .vnc
.bash_history .dmrc .gnome2_private .metacity .Xauthority
.bash_logout .eggcups .gstreamer-0.10 .nautilus .xsession-errors
.bash_profile .gconf .gtkrc-1.2-gnome2 .redhat
[root@localhost ~]# cd .vnc/
[root@localhost .vnc]# ls
localhost.localdomain:1.log localhost.localdomain:1.pid passwd xstartup
[root@localhost .vnc]# ll
total 16
-rw-r--r-- 1 root root 556 May 19 10:28 localhost.localdomain:1.log
-rw-r--r-- 1 root root 5 May 19 10:28 localhost.localdomain:1.pid
-rw------- 1 root root 8 May 19 10:28 passwd
-rwxr-xr-x 1 root root 334 May 19 10:28 xstartup
[root@localhost .vnc]#
[root@localhost .vnc]# netstat -ntpl|grep vnc
tcp 0 0 0.0.0.0:5801 0.0.0.0:* LISTEN 3480/Xvnc
tcp 0 0 0.0.0.0:5901 0.0.0.0:* LISTEN 3480/Xvnc
tcp 0 0 0.0.0.0:6001 0.0.0.0:* LISTEN 3480/Xvnc
tcp 0 0 :::6001 :::* LISTEN 3480/Xvnc
在windows主机上安装VNC客户端:
# unset SESSION_MANAGER
# exec /etc/X11/xinit/xinitrc
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
xterm -geometry 80x24 10 10 -ls -title "$VNCDESKTOP Desktop" &
twm &
把上面两行的注释去掉后,重启VNCSERVER
Killing Xvnc process ID 3480
[root@localhost .vnc]# vncserver :1
Log file is /root/.vnc/localhost.localdomain:1.log
这时再使用xp上的vnc viewer就可以远程linux图形界面了。
(注:VNC viewer for Java需要JRE支持,如果页面无法显示,表示没有安装JRE,可以到 http://java.sun.com/javase/downloads/index_jdk5.jsp下载最新的JRE,然后在客户机上进行安装)。
# The VNCSERVERS variable is a list of display:user pairs.
#
# Uncomment the line below to start a VNC server on display : 1
# as my ’myusername’ (adjust this to your own). You will also
# need to set a VNC password ; run ’man vncpasswd’ to see how
# to do that.
#
# DO NOT RUN THIS SERVICE if your local area network is
# untrusted! For a secure way of using VNC , see
# .
VNCSERVERS
= “ 1:user1 2:user2 3:user3 “
VNCSERVERARGS [ 1 ] = “ -geometry 1024×768 “
VNCSERVERARGS [ 2 ] = “ -geometry 1024×768 “
VNCSERVERARGS [ 3 ] = “ -geometry 800×600 “
解释一下这个文件:
VNCSERVERS这一行是配置在系统启动时启动几个VNC server,上面的例子里运行了三个VNC server,其中user1在display :1,user2在display :2,user3在display :3。
VNCSERVERARGS这三行,分别为VNC server 1, 2, 3配置启动参数,上面的例子里对user1和user2使用屏幕分辨率1024×768,对user3使用800×600
其它支持的参数请使用“man vncserver”命令查询。
编辑好这个文件后,保存,然后以root身份运行:
/sbin/service vncserver start
这样user1, user2, user3的vncserver就启动了。
以后每次系统重启时,都会自动启动这三个用户的vncserver。
注意:上面三个用户必须已经使用vncpasswd命令设置过vnc密码,不然他的vncserver启动会失败!
[root@localhost ~]# service vncserver restart
Shutting down VNC server: 1:root 2:lisi 3:tom [ OK ]
Starting VNC server: 1:root
New 'localhost.localdomain:1 (root)' desktop is localhost.localdomain:1
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/localhost.localdomain:1.log
2:lisi
New 'localhost.localdomain:2 (lisi)' desktop is localhost.localdomain:2
Starting applications specified in /home/lisi/.vnc/xstartup
Log file is /home/lisi/.vnc/localhost.localdomain:2.log
3:tom
New 'localhost.localdomain:3 (tom)' desktop is localhost.localdomain:3
Starting applications specified in /home/tom/.vnc/xstartup
Log file is /home/tom/.vnc/localhost.localdomain:3.log
[ OK ]
[root@localhost ~]#
使用VNC View远程访问Linux,总是没有办法切换出SCIM输入法,研究了很久,终于让我找到了解决 方法 。
1)修改.vnc/xstartup文件,在最后一行加入:scim -d,意思为打开SCIM输入法
2)使用VNC View访问Linux系统以后,修改scim输入法的快捷键,因为默认打开输入法的快捷键为ctrl space,与本地机器上切换输入法的快捷键冲 突,系统 会先接收到本地的命令,所以没办法使用默认快捷键打开输入法。将打开SCIM输入法的快捷键修改为Ctrl Alt Space。
在windows上安装vnc服务器,使用vnc4.0.rar这个软件,最好不要使用企业版的。安装时可以设置一个远程时的验证密码,安装好后使用linux下的vnc viewer远程就可以了,只需要输入windows的IP就可以了。