Chinaunix首页 | 论坛 | 博客
  • 博客访问: 429330
  • 博文数量: 79
  • 博客积分: 8385
  • 博客等级: 中将
  • 技术积分: 3625
  • 用 户 组: 普通用户
  • 注册时间: 2005-09-26 14:42
文章分类

全部博文(79)

文章存档

2011年(10)

2010年(40)

2009年(21)

2008年(8)

分类: LINUX

2010-09-27 09:00:55

 

The following steps will autostart a VNC server on a Red Hat Enterprise Linux 5.x or CentOS 5.x operating system after a reboot. The Linux user account that needs VNC server to automatically start up after system reboot, must have a VNC password. To create a new (or reset a forgotten) VNC password, just login as root or su (switch user) with that Linux user account and execute this simple command:

vncpasswd

Enter a password when prompted, which is used for VNC authentication. A hidden directory named .vnc is created in the user home directory by the vncpasswd command (if it’s not current exists).

To check if the file xstartup exists, execute:

1.ls -la $HOME/.vnc

If it does not exist, type:

1.vncserver :1

If you get a similar message "A VNC server is already running as :1", then another instance of VNC server running with the same display number. To resolve this, just try to replace the :1 with :2, :3, etc. Alternatively, you may execute this netstat command with root user privilege:

1.# netstat -tulpan | grep vnc
2.tcp 0 0 0.0.0.0:5801 0.0.0.0:* LISTEN 3402/Xvnc
3.tcp 0 0 0.0.0.0:5802 0.0.0.0:* LISTEN 8447/Xvnc
4.tcp 0 0 0.0.0.0:5901 0.0.0.0:* LISTEN 3402/Xvnc
5.tcp 0 0 0.0.0.0:5902 0.0.0.0:* LISTEN 8447/Xvnc
6.tcp 0 0 0.0.0.0:6001 0.0.0.0:* LISTEN 3402/Xvnc
7.tcp 0 0 0.0.0.0:6002 0.0.0.0:* LISTEN 8447/Xvnc

The netstat output shows that there are two VNC servers running with display number 1 and 2. So, for the 3rd VNC server to start, the command should be vncserver :3.

Edit $HOME/.vnc/xstartup file to un-comment two lines in order to get the "normal" Linux Desktop view:

1.unset SESSION_MANAGER
2.exec /etc/X11/xinit/xinitrc

Switch user to root account (i.e. su - root), edit /etc/sysconfig/vncservers and append the display number and Linux user account information to the VNCSERVERS (an array variable). This configuration file defines who can start up VNC server with what display number via the VNCSERVERS array (that’s read by Linux start up scripts /etc/init.d/vncserver). For example,

1.VNCSERVERS="1:root 2:tester 3:anotheruser"

That means there are three Linux user accounts (root, tester, and anotheruser) will start up VNC server with display number 1, 2, and 3 respecitively, as Linux boots up.

Note: Don’t simply add more than one VNCSERVERS array in /etc/sysconfig/vncserver configuration file. Otherwise, only the last VNCSERVERS array will be used.

Ensure the VNC server (the daemon or server process) is set to autorun on system boots to your runlevel. For example,

1.# chkconfig ––list | grep vnc
2.vncserver 0:off 1:off 2:off 3:off 4:off 5:on 6:off

The ––list option of chkconfig shows VNC server is set to auto run in Linux runlevel 5 (the default multi-user runlevel with Linux Desktop console). To configure VNC server to auto run when Linux boots into runlevel 5, use the ––level with on option switch:

1.chkconfig --level 5 vncserver on

To check if this configuration works, you can reboot the computer

1.shutdown -r now

Tested and worked: April 20, 2010 on Red Hat Enterprise Linux 5.3 and CentOS 5.4.

Source:

阅读(505) | 评论(0) | 转发(1) |
0

上一篇:Kill/Make HMC Session

下一篇:关于java多态性

给主人留下些什么吧!~~