1. Verify that VNC is installed
By default, the Red Hat Enterprise Linux Installer installs the VNC service on the system.
Verify that the VNC service is installed and view the installed VNC version
[root@testdb ~]# rpm -q vnc-servervnc-server-4.1.2-9.el5[root@testdb ~]#
If the system is not installed, you can find the RPM installation package vnc-server-4.1.2-9.el5.x86_64.rpm of the VNC service under the server directory of the operating system installation disk, the installation command is as follows
rpm -ivh /mnt/Server/vnc-server-4.1.2-9.el5.x86_64.rpm
2. Start the VNC service
Use the Vncserver command to start the VNC service, the command format is "Vncserver: Desktop Number", where "desktop number" as a "number" means, each user needs to occupy 1 desktop
Start a desktop with a number of 1 for example, below
[Root@testdb~]# vncserver:1You'llrequireA password to access your desktops.Password:Verify:Xauth: creatingNewAuthority file/root/. Xauthoritynew' testdb:1 (root) 'Desktop is TestDB:1Creatingdefaultstartup script./root/. vnc/xstartupstarting applications specifiedinch /root/. vnc/xstartuplog file is /root/. vnc/TestDB:1.Log
During the execution of the above command, because it is the first time to execute, you need to enter a password, this password is encrypted in the user's home directory in the. VNC subdirectory (/ROOT/.VNC/PASSWD), and the user's home directory in the. VNC subdirectory automatically establishes the Xstartup profile ( /root/.vnc/xstartup), the configuration information from the file is read every time the VND service is started.
There is also a "testdb:1.pid" file under the btw:/root/.vnc/directory that records the process number that corresponds to the acquired operating system after VNC is started, which is used to accurately locate 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 with 5900, the corresponding relationship is as follows
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 service TCP port starts at 5800 and is 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 Linux turned on the firewall function, you need to manually open the appropriate port to open the desktop number "1" the corresponding port as an example, the command is as follows
[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 method is to use the VNC viewer software Landing test, the operation process is as follows
Launch VNC viewer software –> Server input "144.194.192.183:1" –> click "OK" –> password Enter login password –> Click "OK" Login to X-window graphical desktop environment –> test Success
The second method is to use a Web browser (such as Firefox,ie,safari) to log on to the test, the following procedures
The Address bar input http://144.194.192.183:5801/–> appears in the VNC Viewer for Java (this tool is a VNC client program written in Java) interface, while jumping out of the VNC Viewer dialog box, at the server input " 144.194.192.183:1 "click" OK "–> password enter the login password –> click" OK "Login to X-window graphical desktop environment –> test success
(Note: VNC Viewer for Java requires JRE support, if the page cannot be displayed, indicating that no JRE is installed, you can download the latest JRE to http://java.sun.com/javase/downloads/index_jdk5.jsp here for installation)
5. Configure the VNC graphical desktop environment for the KDE or GNOME desktop environment
If you are configured according to my method above, landing on the desktop after the effect is very simple, only one shell to use, this is why? How can I see a cute and beautiful KDE or GNOME desktop environment? Answer as follows
It's so ugly because the VNC service uses the TWM graphical desktop environment by default and can be modified in the VNC configuration file Xstartup, first look at this configuration file
[[email protected] ~]# vi /root/.vnc/xstartup#!/bin/sh# Uncomment the following two lines for normal desktop:# unset SESSION_MANAGER# exec /etc/X11/xinit/xinitrc
exec$HOME$HOME80x24+10+10"$VNCDESKTOP Desktop" &twm &
Change the last line of this xstartup file to "Startkde &", and then restart the Vncserver service to log in to the KDE desktop environment
Change the last line of this xstartup file to "Gnome-session &", and then restart the Vncserver service to log in 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 use the following method to start VNC for multiple desktops
Vncserver:1
Vncserver:2
Vncserver:3
......
However, this method of manual startup will expire after the server restarts, so here's how to get the system to automatically manage VNC for multiple desktops by adding information that needs to be managed automatically to the/etc/sysconfig/vncservers configuration file. The following is the example of a desktop 1 root user Desktop 2 for an Oracle User:
Format: vncservers= "desktop number: User name to use Desktop number: User name used"
[root@testdb ~]# vi /etc/sysconfig/vncserversVNCSERVERS="1:root 2:oracle"VNCSERVERARGS[1]="-geometry 1024x768"VNCSERVERARGS[2]="-geometry 1024x768"
7. Modify the password for VNC access
Using the command vncpasswd to modify the VNC password for different users, it is important to note that if VNC is configured with different users, it needs to be modified separately to the respective user, for example, in my experiment, the root user and Oracle user need to modify the process as follows:
[root@testdb ~]# vncpasswdPassword:Verify:[root@testdb ~]#
8. Start and stop the VNC service
1) Start the VNC service command
[root@testdb ~]# /etc/init.d/vncserver startserver1‘testdb:1 (root)‘istestdb:1in/root/is/root/.vnc/testdb:1.log
2:oracle
New‘testdb:2is testdb:2infileis /home/oracle/.vnc/testdb:2.log [ OK ]
2) Stop the VNC service command
[root@testdb ~]# /etc/init.d/vncserver stopShuttingVNCserver:1:root2:oracle [ OK ]
3) Restart the VNC service command
[root@testdb ~]# /etc/init.d/vncserver restartserver12:oracle [ OK server1‘testdb:1 (root)‘istestdb:1in/root/is/root/.vnc/testdb:1.log
2:oracle
New‘testdb:2is testdb:2infileis /home/oracle/.vnc/testdb:2.log [ OK ]
4) Set up VNC service to load automatically with system boot
The first method: Use the "NTSYSV" command to start the graphical service configurator, add an asterisk before the Vncserver service, click OK, and the configuration is complete.
The second method: use "Chkconfig" in the command-line mode of operation, command using the following (predict Chkconfig detailed use method please self-help man a bit)
[root@testdb ~]# chkconfig vncserver on[root@testdb ~]# chkconfig --list vncservervncserver 0:off 1:off 2:on 3:on 4:on 5:on 6:off
9. Summary
The detailed configuration method of VNC has been finished, hoping to be helpful to everyone. VNC is very lightweight and convenient for remotely invoking a graphical interface, making use of it!
Good luck.
Secooler
09.06.25
, Haven end–
"VNC" Linux environment VNC service installation, configuration and use