linux VNCserver配置 (linux 远程桌面)
目前linux系统都自带VNC
Linux操作系统最流行的图形化操作软件是VNC,正如windows下的mstsc远程桌面,在大多数 Linux 发行版都带了 VNC Server 的发行包,通过rpm -qa|grep vnc检查,若没有,下载rpm包进行安装即可.
1.[root@localhost ~]# rpm -qa|grep vnc
vnc-4.1.2-14.el5_3.1
vnc-server-4.1.2-14.el5_3.1
2.启动服务器端的VNC 服务
[root@localhost ~]# /etc/init.d/vncserver start
Starting VNC server:                                      [  OK  ]
目前linux系统都自带VNC,不用安装
启动VNC
[root@localhost ~]# service vncservice restart
3.运行 vncserver 命令,如果第一次配置 VNC Server,会要求提供登录 VNC 使用的密码。以后也可以使用 vncpasswd 来修改密码。
[root@localhost ~]# vncserver
You will require a password to access your desktops.
Password:
Verify:
New ‘localhost.localdomain:1 (root)’ desktop is localhost.localdomain:1
Creating default startup script /root/.vnc/xstartup
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/localhost.localdomain:1.log
4.修改配置文件 /root/.vnc/xstartup
[root@localhost ~]# cat /root/.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 &
xterm -geometry 80×24+10+10 -ls -title “$VNCDESKTOP Desktop” &
twm &
5. Windows 使用 VNC Viewer 登录了
输入服务器地址:ip:1
然后提示输入密码,输入你刚才设定的密码就好了.
注意:IP 地址后面的 :1 的意思是 Linux 上面 VNC 设定的 Display No. 每运行一个 vncserver 就会多创建一个 Displaylinux系统安装步骤csdnDisplay No 也就会加1
6. SSH终端中输入 vncserver,让 VNC 打开一个新的 Display
[root@localhost ~]# vncserver             
New ‘localhost.localdomain:2 (root)’ desktop is localhost.localdomain:2
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/localhost.localdomain:2.log
附一些常见的问题:
VNC Viewer下载地址:download.csdn/source/1080853
以后如果服务器重新启动过,就要重新输入 vncserver 后才能登录。如果服务器一直没有重启过,就不用了。如果要杀掉 vncserver 进程,可执行 vncserver :1 kill 1表示 display ID 号。
(1) 重设VNC密码
[root@localhost ~]# vncpasswd
Password:
Verify:
(2) 启动和kill vncserver
[root@localhost ~]# vncserver :23
New ‘localhost.localdomain:23 (root)’ desktop is localhost.localdomain:23
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/localhost.localdomain:23.log
如下:kill  display ID 1,1pid:6653
[root@localhost ~]# ps -auxwf|grep vnc|grep -v grep
Warning: bad syntax, perhaps a bogus ‘-’? See /usr/share/doc/procps-3.2.7/FAQ
root      6653  0.0  1.3  13660  6836 pts/0    S    04:44  0:00 Xvnc :1 -desktop localhost.localdomain:1 (root) -httpd /usr/share/vnc/classes -auth /root/.Xauthority -geometry 1024×768 -depth 16 -rfbwait 30000 -rfbauth /root/.vnc/passwd -rfbport 5901 -pn
root      6661  0.0  0.2  4276  1304 pts/0    S    04:44  0:00 vncconfig -iconic
root      6716  0.1  2.1  20972 11276 pts/0    S    04:51  0:01 Xvnc :2 -desktop localhost.localdomain:2 (root) -httpd /usr/share/vnc/classes -auth /root/.Xauthority -geometry 1024×768 -depth 16 -rfbwait 30000 -rfbauth /root/.vnc/passwd -rfbport 5902 -pn
root      6936  0.4  2.1  20856 11116 pts/0    S    05:06  0:00 Xvnc :23 -desktop localhost.localdomain:23 (root) -httpd /usr/share/vnc/classes -auth /root/.Xauthority -geometry 1024×768 -depth 16 -rfbwait 30000 -rfbauth /root/.vnc/passwd -rfbport 5923 -pn
[root@localhost ~]# kill -9 6653
[root@localhost ~]# ps -auxwf|grep vnc|grep -v grep
Warning: bad syntax, perhaps a bogus ‘-’? See /usr/share/doc/procps-3.2.7/FAQ
root      6716  0.1  2.1  20972 11276 pts/0    S    04:51  0:01 Xvnc :2 -desktop localhost.localdomain:2 (root) -httpd /usr/share/vnc/classes -auth /root/.Xauthority -geometry 1024×768 -depth 16 -rfbwait 30000 -rfbauth /root/.vnc/passwd -rfbport 5902 -pn
root      6936  0.3  2.1  20856 11116 pts/0    S    05:06  0:00 Xvnc :23 -desktop localhost.localdomain:23 (root) -httpd /usr/share/vnc/classes -auth /root/.Xauthority -geometry 1024×768 -depth 16 -rfbwait 30000 -rfbauth /root/.vnc/passwd -rfbport 5923 -pn
当然,vncserver -kill :2也可以了,
[root@localhost ~]# vncserver -kill :2
Killing Xvnc process ID 6716
[root@localhost ~]# ps -auxwf|grep vnc|grep -v grep
Warning: bad syntax, perhaps a bogus ‘-’? See /usr/share/doc/procps-3.2.7/FAQ
root      6936  0.2  2.1  20856 11116 pts/0    S    05:06  0:00 Xvnc :23 -desktop localhost.localdomain:23 (root) -httpd /usr/share/vnc/classes -auth /root/.Xauthority -geometry 1024×768 -depth 16 -rfbwait 30000 -rfbauth /root/.vnc/passwd -rfbport 5923 -pn
3)重新启动一个手动killvncserver
[root@localhost ~]# vncserver :1
Warning: localhost.localdomain:1 is taken because of /tmp/.X1-lock

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。