"VNC" Linux environment VNC service installation, configuration and use

Source: Internet
Author: User

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
[Email protected] ~]# rpm-q vnc-server
Vnc-server-4.1.2-9.el5
[Email protected] ~]#

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
[Email protected] ~]# 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 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
The desktop number is "1"----port number is 5901
The desktop number is "2"----port number is 5902
The 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
The desktop number is "1"----port number is 5801
The desktop number is "2"----port number is 5802
The 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
[[email protected] ~]# iptables-i input-p TCP--dport 5901-j ACCEPT
[[email protected] ~]# 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 the VNC viewer software---server input "144.194.192.183:1"-click "OK"-Password enter the login password-click "OK" to log into the X-window graphical desktop environment--& Gt 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
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, while jumping out of the VNC Viewer dialog box, enter "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-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 &

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:
[Email protected] ~]# vncserver-kill:1
[Email protected] ~]# 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"
[Email protected] ~]# 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 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:
[Email protected] ~]# VNCPASSWD
Password:
Verify:
[Email protected] ~]#

8. Start and stop the VNC service
1) Start the VNC service command
[[email protected] ~]#/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 the VNC service command
[[email protected] ~]#/etc/init.d/vncserver stop
Shutting down VNC server:1:root 2:oracle [OK]

3) Restart the VNC service command
[Email protected] ~]#/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 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)
[Email protected] ~]# chkconfig vncserver on
[Email protected] ~]# chkconfig--list vncserver
Vncserver 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!

"VNC" Linux environment VNC service installation, configuration and use

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.