A detailed explanation of VNC installation configuration method in Linux system

Source: Internet
Author: User
Tags iptables

1. Confirm that VNC is installed

By default, the Red Hat Enterprise Linux Installer installs the VNC service on the system.
Confirm that VNC service is installed and view the installed VNC version
[Root@testdb ~]# rpm-q Vnc-server
Vnc-server-4.1.2-9.el5
[Root@testdb ~]#

If the system is not installed, you can go to the operating system installation disk in the server directory to find VNC service RPM package vnc-server-4.1.2-9.el5.x86_64.rpm, installation commands are as follows
rpm-ivh/mnt/server/vnc-server-4.1.2-9.el5.x86_64.rpm

2. Start VNC Service

Use the Vncserver command to start the VNC service, the command format is "Vncserver: Desktop Number", where "desktop number" in the form of "digital" means that each user needs to occupy 1 desktop
An example of a desktop with a startup number of 1 is shown below
[Root@testdb ~]# Vncserver:1

You'll require a password to access your desktops.

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

During the execution of the above command, because it is the first execution, a password is required to be encrypted and stored in the. VNC subdirectory (/ROOT/.VNC/PASSWD) in the user's home directory, and the Xstartup configuration file is automatically established for users in the. VNC subdirectory under the user's home directory ( /root/.vnc/xstartup), the configuration information in the file is read every time the VND service is started.
The btw:/root/.vnc/directory also has a "testdb:1.pid" file that records the process number that corresponds to the acquired operating system after the start of VNC, and the exact location of the process number when the VNC service is stopped.

The relationship between the port number used by the 3.VNC service and the desktop number

The port number used by the VNC service is related to the desktop number, and VNC uses the TCP port starting at 5900, which corresponds to the following
Desktop number is "1"----port number is 5901
Desktop number is "2"----port number is 5902
Desktop number is "3"----port number is 5903
......
The Java-based VNC client Web Services TCP port starts at 5800 and is also related to the desktop number, which corresponds to the following
Desktop number is "1"----port number is 5801
Desktop number is "2"----port number is 5802
Desktop number is "3"----port number is 5803
......
Based on the above introduction, if the Linux firewall features, you need to manually open the appropriate port, to open the desktop number of "1" the corresponding port for example, the following command
[Root@testdb ~]# iptables-i input-p tcp--dport 5901-j ACCEPT
[Root@testdb ~]# iptables-i input-p tcp--dport 5801-j ACCEPT

4. Test VNC Service

The first approach is to use the VNC Viewer software to log on to the test, the following procedure
Start the VNC viewer software--> Server input "144.194.192.183:1"--> click "OK"--> password Enter login password--> Click "OK" landing to X-window graphics desktop environment--& Gt Test successful
The second approach is to use a Web browser (such as Firefox,ie,safari) to log in to the test, the following procedure
Address bar input http://144.194.192.183:5801/--> The VNC viewer for Java (This tool is a VNC client program written in Java) interface, and also out of the Vnc Viewer dialog box, enter the server "144.194.192.183:1" click "OK"--> password Enter login password--> Click "OK" landing to X-window graphics desktop environment--> test success
(Note: VNC Viewer for Java requires JRE support, and if the page cannot be displayed, it means that the JRE is not installed, and you can download the latest JRE to the http://java.sun.com/javase/downloads/index_jdk5.jsp for installation)

5. Configure VNC Graphics desktop environment for KDE or GNOME desktop environment

If you are configured according to my method above, landing on the desktop is very simple, only a shell to use, this is why? How do you see the lovely and beautiful KDE or GNOME desktop environment? Answer as follows
The reason it's so ugly is because VNC services use the TWM Graphics desktop environment by default, which can be modified in VNC's profile xstartup to look at the configuration file first
[Root@testdb ~]# 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 80x24+10+10-ls-title "$VNCDESKTOP Desktop" &
TWM &

Modify the last line of the Xstartup file to "Startkde &" and then restart the Vncserver service to log on to the KDE desktop environment
Modify the last line of the Xstartup file to "Gnome-session &" and then restart the Vncserver service to log on to the GNOME desktop environment

How to restart the Vncserver service:
[Root@testdb ~]# Vncserver-kill:1
[Root@testdb ~]# Vncserver:1

6. Configure multiple Desktops

You can start VNC on multiple desktops using the following methods
Vncserver:1
Vncserver:2
Vncserver:3
......
However, this manual-initiated approach will fail after the server restarts, so here's how to automate the system to manage multiple desktop VNC by adding information that needs to be managed automatically to the/etc/sysconfig/vncservers configuration file. Use desktop 1 for root Desktop 2 as an example for Oracle users as follows:
Format: vncservers= "desktop number: User name Desktop Number: Use username"
[Root@testdb ~]# Vi/etc/sysconfig/vncservers
vncservers= "1:root 2:oracle"
vncserverargs[1]= "-geometry 1024x768"
vncserverargs[2]= "-geometry 1024x768"

7. Modify the password for VNC access

Using the command vncpasswd to change the password of VNC for different users, it is important to note that VNC with different users needs to be modified separately from the respective users, for example, in my experiment, root and Oracle users need to be modified separately, and the modification process is as follows:
[Root@testdb ~]# vncpasswd
Password:
Verify:
[Root@testdb ~]#

8. Start and stop VNC service

1 Start VNC Service command
[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) Stop VNC Service command

[Root@testdb ~]#/etc/init.d/vncserver Stop
Shutting down VNC server:1:root 2:oracle [OK]

3 Restart VNC Service command

[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) Set up VNC service to load automatically with system startup


The first method: Use the "NTSYSV" command to start the graphical service configuration program, add an asterisk before the Vncserver service, click OK, configuration complete.
The second approach is to use "chkconfig" to operate in command-line mode, using the following commands (for predictive chkconfig detailed usage please help yourself man)
[Root@testdb ~]# chkconfig vncserver on
[Root@testdb ~]# chkconfig--list vncserver
Vncserver 0:off 1:off 2:on 3:on 4:on 5:on 6:off

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.