VNC设置

来源:互联网 发布:怎么删除淘宝下架宝贝 编辑:程序博客网 时间:2024/05/17 03:05

Oracle在Linux上的安装需要用到图形界面(静默安装除外),身体好的同志完全可以在机房里面顶着做,身体素质一般的还是老老实实的远程操作吧。方便起见我们就使用Linux自带的vnc-server。

首先查看是否安装了vnc-server服务:

[root@localhost ~]# rpm -qa vnc-server

vnc-server-4.0-8.1

如果没有安装则上传安装包安装即可,安装完成以后运行vncserver,如果用户是第一次运行需要设置vnc密码,否则不需要设置。

[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

上面的这段话表示启动了一个图形终端,编号为1。现在我们就可以通过vncviewer等工具远程连接服务器了,在连接的时候需要提供图形终端号。连接上以后会发现图形界面相当的丑陋,因为默认的图像终端使用的是xterm+twm,我们可以通过修改启动脚本将gnome或kde作为默认的图像终端。编辑用户home目录下的/.vnc/xstartup,将twm替换为gnome-session并重启vncserver即可。

[root@localhost ~]# vi /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 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &

gnome-session &

 

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

Killing Xvnc process ID 4117

 

[root@localhost ~]# vncserver

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

如果有多个用户需要使用图形终端,我们一个一个的去修改就显的很麻烦了,可以通过编辑/usr/bin/vncserver实现新增用户默认图形终端的设置。找到以下代码:

$defaultXStartup

= ("#!/bin/sh/n/n".
       "# Uncomment the following two lines for normal desktop:/n".
       "# unset SESSION_MANAGER/n".
       "# exec /etc/X11/xinit/xinitrc/n/n".
       "[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup/n".
       "[ -r /$HOME/.Xresources ] && xrdb /$HOME/.Xresources/n".
       "xsetroot -solid grey/n".
       "vncconfig -iconic &/n".
       "xterm -geometry 80x24+10+10 -ls -title /"/$VNCDESKTOP Desktop/" &/n".
       "twm &/n");

将红色部分的注释符号去掉,并将其余的行加上注释符#即可。如下:

$defaultXStartup

= ("#!/bin/sh/n/n".
       "# Uncomment the following two lines for normal desktop:/n".
       "unset SESSION_MANAGER/n".
       "exec /etc/X11/xinit/xinitrc/n/n".

       "# [ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup/n".
       "# [ -r /$HOME/.Xresources ] && xrdb /$HOME/.Xresources/n".
       "# xsetroot -solid grey/n".
       "# vncconfig -iconic &/n".
       "# xterm -geometry 80x24+10+10 -ls -title /"/$VNCDESKTOP Desktop/" &/n".
       "# twm &/n");

原创粉丝点击