The most popular graphic operating software in Linux is VNC. Just like the mstsc Remote Desktop in windows, most Linux releases contain the VNC Server Release package, run the rpm-Qa | grep VNC check. If no, download the RPM package and install it.
1. [root @ localhost ~] # Rpm-Qa | grep VNC
Vnc-4.1.2-14.el5_3.1
Vnc-server-4.1.2-14.el5_3.1
2. Start the VNC service on the server.
[Root @ localhost ~] #/Etc/init. d/vncserver start
Starting VNC Server: [OK]
3. Run the vncserver command. If you configure the VNC server for the first time, the password used to log on to the VNC is required. You can also use vncpasswd to change the password later.
[Root @ localhost ~] # Vncserver
You will require a password to access your tops.
Password:
Verify:
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
4. modify the configuration file/root/. VNC/xstartup
[Root @ localhost ~] # Cat/root/. VNC/xstartup. Remove the comments of the following two lines.
#! /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 gray
Vncconfig-iconic &
Xterm-geometry 80 × 24 + 10 + 10-ls-title "$ vncdesktop desktop "&
TWM &
5. log on to Windows using VNC Viewer
Enter the server address: IP: 1
Then, you will be prompted to enter the password you just set.
Note: The IP address is followed by: 1, which indicates the display no set by VNC in Linux. Each time a vncserver is run, an additional display is created, and 1 is added to display no.
6. Enter vncserver In the SSH terminal to open a new display in VNC.
[Root @ localhost ~] # Vncserver
New 'localhost. localdomain: 2 (Root) 'desktop is localhost. localdomain: 2
Starting applications specified in/root/. VNC/xstartup
Log File is/root/. VNC/localhost. localdomain: 2.log
Some common problems are attached:
VNC Viewer: http://download.csdn.net/source/1080853
If the server is restarted later, you need to re-enter the vncserver before you can log on. If the server has never been restarted, you do not need. If you want to kill the vncserver process, run vncserver: 1 kill. 1 indicates the ID of the display.
(1) reset the VNC Password
[Root @ localhost ~] # Vncpasswd
Password:
Verify:
(2) Start and kill vncserver
[Root @ localhost ~] # Vncserver: 23
New 'localhost. localdomain: 23 (Root) 'desktop is localhost. localdomain: 23
Starting applications specified in/root/. VNC/xstartup
Log File is/root/. VNC/localhost. localdomain: 23.log
The PID of ID 6653 of kill display is :.
[Root @ localhost ~] # Ps-auxwf | grep VNC | grep-V grep
Warning: bad syntax, perhaps a bogu '-'? See/usr/share/doc/procps-3.2.7/faq
Root 6653 0.0 1.3 13660 6836 pts/0 s xvnc: 1-desktop localhost. localdomain: 1 (Root)-httpd/usr/share/VNC/classes-auth/root /. xauthority-geometry 1024x768-depth 16-rfbwait 30000-rfbauth/root /. VNC/passwd-rfbport 5901-PN
Root 6661 0.0 0.2 4276 1304 pts/0 s vncconfig-iconic
Root 6716 0.1 2.1 20972 11276 pts/0 s xvnc: 2-desktop localhost. localdomain: 2 (Root)-httpd/usr/share/VNC/classes-auth/root /. xauthority-geometry 1024x768-depth 16-rfbwait 30000-rfbauth/root /. VNC/passwd-rfbport 5902-PN
Root 6936 0.4 2.1 20856 11116 pts/0 s xvnc: 23-desktop localhost. localdomain: 23 (Root)-httpd/usr/share/VNC/classes-auth/root /. xauthority-geometry 1024x768-depth 16-rfbwait 30000-rfbauth/root /. VNC/passwd-rfbport 5923-PN
[Root @ localhost ~] # Kill-9 6653
[Root @ localhost ~] # Ps-auxwf | grep VNC | grep-V grep
Warning: bad syntax, perhaps a bogu '-'? See/usr/share/doc/procps-3.2.7/faq
Root 6716 0.1 2.1 20972 11276 pts/0 s xvnc: 2-desktop localhost. localdomain: 2 (Root)-httpd/usr/share/VNC/classes-auth/root /. xauthority-geometry 1024x768-depth 16-rfbwait 30000-rfbauth/root /. VNC/passwd-rfbport 5902-PN
Root 6936 0.3 2.1 20856 11116 pts/0 s xvnc: 23-desktop localhost. localdomain: 23 (Root)-httpd/usr/share/VNC/classes-auth/root /. xauthority-geometry 1024x768-depth 16-rfbwait 30000-rfbauth/root /. VNC/passwd-rfbport 5923-PN
Of course, vncserver-kill: 2 is okay,
[Root @ localhost ~] # Vncserver-kill: 2
Killing xvnc process ID 6716.
[Root @ localhost ~] # Ps-auxwf | grep VNC | grep-V grep
Warning: bad syntax, perhaps a bogu '-'? See/usr/share/doc/procps-3.2.7/faq
Root 6936 0.2 2.1 20856 11116 pts/0 s xvnc: 23-desktop localhost. localdomain: 23 (Root)-httpd/usr/share/VNC/classes-auth/root /. xauthority-geometry 1024x768-depth 16-rfbwait 30000-rfbauth/root /. VNC/passwd-rfbport 5923-PN
(3) restart a manually killed vncserver.
[Root @ localhost ~] # Vncserver: 1
Warning: localhost. localdomain: 1 is taken because of/tmp/. X1-lock
Remove this file if there is no X Server localhost. localdomain: 1
A vnc Server is already running as: 1
[Root @ localhost ~] # Rm-RF/tmp/. X1-lock
[Root @ localhost ~] # Vncserver: 1
Warning: localhost. localdomain: 1 is taken because of/tmp/. X11-unix/X1
Remove this file if there is no X Server localhost. localdomain: 1
A vnc Server is already running as: 1
[Root @ localhost ~] # Rm-RF/tmp/. X11-unix/X1
[Root @ localhost ~] # Vncserver: 1
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
[Root @ localhost ~] #
[Root @ localhost ~] # Ps-auxwf | grep VNC | grep-V grep
Warning: bad syntax, perhaps a bogu '-'? See/usr/share/doc/procps-3.2.7/faq
Root 6936 0.0 2.4 22296 12680 pts/0 s xvnc: 23-desktop localhost. localdomain: 23 (Root)-httpd/usr/share/VNC/classes-auth/root /. xauthority-geometry 1024x768-depth 16-rfbwait 30000-rfbauth/root /. VNC/passwd-rfbport 5923-PN
Root 7337 1.0 2.1 20252 10856 pts/0 s xvnc: 1-desktop localhost. localdomain: 1 (Root)-httpd/usr/share/VNC/classes-auth/root /. xauthority-geometry 1024x768-depth 16-rfbwait 30000-rfbauth/root /. VNC/passwd-rfbport 5901-PN
Note: because it is manually deleted, you must delete the. Lock to restart it.
(4) Relationship between the port number used by the VNC service and the desktop number
The port number used by the VNC service is related to the desktop number. The VNC uses the TCP port starting from 5900. The corresponding relationship is as follows:
Desktop number is "1" -- port number is 5901
Desktop number "2" -- port number is 5902
Desktop number "3" -- port number is 5903
......
The TCP port of the Java-based VNC client web service starts from 5800 and is also related to the desktop number. The corresponding relationship is as follows:
Desktop number is "1" -- port number is 5801
Desktop number "2" -- port number is 5802
Desktop number "3" -- port number is 5803
......
Based on the above introduction, if the firewall function is enabled in Linux, You need to manually enable the corresponding port. For example, to enable the corresponding port with the desktop number "1", the command is as follows:
[Root @ localhost ~] # Iptables-I input-P TCP-dport 5901-J accept
[Root @ localhost ~] # Iptables-I input-P TCP-dport 5801-J accept
(5) configure the VNC graphic desktop environment as KDE or GNOME Desktop Environment
[Root @ localhost ~] # 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 gray
Vncconfig-iconic &
Xterm-geometry 80 × 24 + 10 + 10-ls-title "$ vncdesktop desktop "&
TWM &
Change the last line of the xstartup file to "startkde &", restart the vncserver service, and then log on to the KDE Desktop Environment.
Change the last line of the xstartup file to "gnome-session &", restart the vncserver service, and then log on to the GNOME desktop environment.
To restart the vncserver service, follow these steps:
[Root @ localhost ~] # Vncserver-kill: 1
[Root @ localhost ~] # Vncserver: 1
(6) Configure multiple desktops
You can use the following method to start VNC for multiple desktops
Vncserver: 1
Vncserver: 2
......
However, this manual start method will expire after the server is restarted. Therefore, the following describes how to enable the system to automatically manage VNC on multiple desktops, add the information to be automatically managed to the/etc/sysconfig/vncservers configuration file,
Take desktop 1 as the test user desktop 2 as the test1 user as an example to configure the following:
Format: vncservers = "desktop number: used user name"
[Root @ localhost ~] # Vi/etc/sysconfig/vncservers
Vncservers = "1: Test 2: test1 ″
Vncserverargs [1] = "-geometry 1024 × 768 ″
Vncserverargs [2] = "-geometry 1024 × 768 ″
(7) set the VNC service to automatically load as the system starts
Method 1: run the "ntsysv" command to start the graphical service configuration program. Add an asterisk to The vncserver service and click "OK". The configuration is complete.
Method 2: Use "chkconfig" to operate in command line mode. Use the following command:
[Root @ localhost ~] # Chkconfig vncserver on
[Root @ testdb ~] # Chkconfig-list vncserver
Vncserver 0: off 1: off 2: On 3: On 4: On 5: on 6: Off
Method 3: add the command/etc/init. d/vncserver start to the/etc/rc. Local startup Item.
Author: Sun Jianhe
Address: http://www.sunjianhe.com /? P = 685
The author and original source must be indicated in the form of links when all copyrights are reprinted!