Remote control linux By vnc-server

来源:互联网 发布:天刀捏脸数据女刘亦菲 编辑:程序博客网 时间:2024/05/16 16:10

1.Do it!

Install:    yum install vnc-server

Start:     vncserver :1

input password
Password:
Verify:
xauth: creating new authority file /root/.Xauthority
New ‘testdb:1 (root)’ desktop is testdb:1
Creating default startup script. /root/.vnc/xstartup
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/testdb:1.log

以 上命令执行的过程中,因为是第一次执行,需要输入密码,这个密码被加密保存在用户主目录下的.vnc子目录(/root/.vnc/passwd)中;同 时在用户主目录下的.vnc子目录中为用户自动建立xstartup配置文件(/root/.vnc/xstartup),在每次启动VND服务时,都会 读取该文件中的配置信息。 BTW:/root/.vnc/目录下还有一个“testdb:1.pid”文件,这个文件记录着启动VNC后对应后天操作系统的进程号,用于停止VNC服务时准确定位进程号。


2.VNC服务使用的端口号与桌面号的关系

VNC服务使用的端口号与桌面号相关,VNC使用TCP端口从5900开始,对应关系如下
桌面号为“1” —- 端口号为5901
桌面号为“2” —- 端口号为5902
桌面号为“3” —- 端口号为5903

基于上面的介绍,如果Linux开启了防火墙功能,就需要手工开启相应的端口,以开启桌面号为“1”相应的端口为例,命令如下
[root@testdb ~]# iptables -I INPUT -p tcp –dport 5901 -j ACCEPT
[root@testdb ~]# iptables -I INPUT -p tcp –dport 5801 -j ACCEPT

3.客户端:安装VNC的客户端(VNC Viewer),如realvn.

url:  https://www.realvnc.com/en/download/viewer/macos/

4.Stop And Start Angain

vncserver -kill :1
vncserver :1 (第一次要输入密码后面不用)

5.配置多个桌面

可以使用如下的方法启动多个桌面的VNC
vncserver :1
vncserver :2
vncserver :3

6.启动和停止VNC服务

1)启动VNC服务命令
[root@testdb ~]# /etc/init.d/vncserver start
Starting VNC server: 1:root
New ‘testdb:1 (root)’ desktop is testdb:1

Starting applications specified in /root/.vnc/xstartup Log file is /root/.vnc/testdb:1.log 2:oracle New 'testdb:2 (oracle)' desktop is testdb:2 Starting applications specified in /home/oracle/.vnc/xstartup Log file is /home/oracle/.vnc/testdb:2.log                                                        [  OK  ] 

2)停止VNC服务命令
[root@testdb ~]# /etc/init.d/vncserver stop
Shutting down VNC server: 1:root 2:oracle [ OK ]

3)重新启动VNC服务命令
[root@testdb ~]# /etc/init.d/vncserver restart
Shutting down VNC server: 1:root 2:oracle [ OK ]
Starting VNC server: 1:root
New ‘testdb:1 (root)’ desktop is testdb:1

Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/testdb:1.log

2:oracle
New ‘testdb:2 (oracle)’ desktop is testdb:2

Starting applications specified in /home/oracle/.vnc/xstartup
Log file is /home/oracle/.vnc/testdb:2.log

                                                       [  OK  ] 

4)设置VNC服务随系统启动自动加载
第一种方法:使用“ntsysv”命令启动图形化服务配置程序,在vncserver服务前加上星号,点击确定,配置完成。
第二种方法:使用“chkconfig”在命令行模式下进行操作,命令使用如下(预知chkconfig详细使用方法请自助式man一下)
[root@testdb ~]# chkconfig vncserver on
[root@testdb ~]# chkconfig –list vncserver

原创粉丝点击