linux 查看vnc端口_VNC常用操作及常见问题解决办法汇总

VNC登录用户缺省是root,但在安装oracle时必须用oracle用户的身份登录,下面我们就以oracle为例说明如何配置VNC,从而可以使用不同的用户登录到主机。

步骤描述如下:

步骤一:修改/etc/sysconfig/vncservers,添加oracle用户,修改后内容如下:

VNCSERVERS="1:root 2:root 3:oracle"

VNCSERVERARGS[1]="-geometry 1024x768"

VNCSERVERARGS[2]="-geometry 1024x768"

VNCSERVERARGS[3]="-geometry 1024x768"

步骤二:在系统中新建oracle用户

useradd oracle

passwd oracle

步骤三:将root用户下的路径复制到oracle用户的home路径下,并修改路径所属用户及组:

cp -r /root/.vnc ~oracle/.vnc

chown oracle ~oracle/.vnc/

chown oracle.oinstall -R ~oracle/.vnc/

chown oracle ~oracle/.vnc/*

chown oracle.oinstall -R ~oracle/.vnc/*

步骤四:重启VNC,观察id为3的端口是否启动

service vncserver restart

netstat -anlpt | grep 5903

vnc的端口从5901开始,每增加一个用户,端口号就在5901上加1。如果要单独关闭指定id的端口,可以使用命令:

vncserver -kill :id

如:

vncserver -kill :1

vncserver -kill :2

就将关闭5901和5902两个VNC端口

1、安装

yum install vnc*

2、启动

/etc/init.d/vncserver start

Starting VNC server: no displays configured                [  OK  ]

3、配置用户名

CODE:[root@localhost ~]#  vi /etc/sysconfig/vncservers

# 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

# URL:http://www.uk.research.att.com/vnc/sshvnc.html

# VNCSERVERS="1:myusername"

VNCSERVERS="1:root" (注意:root是CentOS用户名)

如果建2个,可以用VNCSERVERS="1:root 2:linglong"来配置

3.用vncpasswd创建一个vnc的口令

注意这将同时在你的home目录下,创建一个隐藏的目录.vnc,其中有一个文件passwd保存着你的vnc口令.

CODE:

[root@localhost ~]# vncpasswd

Password:

Verify:

[root@localhost ~]# ls -d .vnc

.vnc

[root@localhost ~]# ls .vnc

passwd

4.启动vnc服务.CODE:[root@localhost ~]#  /sbin/service vncserver restart

Shutting down VNC server: 1:root                          [ OK ]

Starting VNC server: 1:root perl: warning: Setting locale failed.

perl: warning: Please check that your locale settings:

LANGUAGE = (unset),

LC_ALL = (unset),

LANG = "zh_EN.UTF-8"

are supported and installed on your system.

perl: warning: Falling back to the standard locale ("C").

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

[ OK ]

察看一下.vnc这个目录的内容,应该类似于下面的东西.

注:在这里我刚开始出现“Warning: *****   is taken because of /tmp/.X1-lock”

在网上找了好多方法,终于找到解决办法了!

我直接将: /tmp/.X1-lock 删除就可以 了 ,命令式: rm /tmp/.X1-lock

如果还出现其他的文件错误 也可照样操作!

CODE:[root@localhost ~]# cd .vnc

[root@localhost .vnc]# ls

localhost.localdomain:1.log localhost.localdomain:2.log passwd

localhost.localdomain:1.pid localhost.localdomain:2.pid xstartup

[root@localhost .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 80x24+10+10 -ls -title "$VNCDESKTOP Desktop"

twm

因为我们已经修改了启动脚本,现在来重新启动vncserver.

CODE:[root@localhost .vnc]#   /sbin/service vncserver restart

Shutting down VNC server: 1:root                          [ OK ]

Starting VNC server: 1:root perl: warning: Setting locale failed.

perl: warning: Please check that your locale settings:

LANGUAGE = (unset),

LC_ALL = (unset),

LANG = "zh_EN.UTF-8"

are supported and installed on your system.

perl: warning: Falling back to the standard locale ("C").

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

[ OK ]

[root@localhost .vnc]#

5.防火墙端口设置

在使用防火墙的情况下来连接到一个远程系统,需要打开端口5901.

加入以下红色的部分,然后重启iptables服务。

[root@localhost ~]#   /sbin/service iptables restart

Flushing firewall rules:                               [   OK   ]

Setting chains to policy ACCEPT: filter                    [   OK   ]

Unloading iptables modules:                                [   OK   ]

Applying iptables firewall rules:                          [   OK   ]

[root@localhost ~]#

vim /root/.vnc/xstartup oracle用户 (/home/oracle/.vnc/xstartup)

twm&(默认文本类型桌面)修改为gnome-session(GNOME风格的桌面环境) startkde & (KDE风格桌面)

Redhat下VNC SERVER的配置

1、启动VNC SERVER

输入vncserver,第一次启动会要求输入验证密码,完成后,VNC SERVER就启动了

[root@localhost ~]# vncserver

You will require a password to access your desktops.

Password:            //输入密码

Verify:                  //再次输入密码

xauth:  creating new authority file /root/.Xauthority

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

[root@localhost ~]#

2、编辑.vnc/xstartup

使用VI打开xstartup文件,如下:

[root@localhost /]# cd /root/.vnc

[root@localhost .vnc]# vi xstartup

删除全部内容,然后添加如下内容:

unset SESSION_MANAGER

exec /etc/X11/xinit/xinitrc

3、重启动VNC SERVER

[root@localhost ~]# vncserver -kill :1

Killing Xvnc process ID 21198

[root@localhost ~]# vncserver

New ‘localhost.localdomain:1 (root)’ desktop is localhost.localdoma

  • 3
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值