Linux open VNCSERVER

Check process: rpm -qa | grep vnc
Start service: vncserver
Restart service: service vncserver restart
Stop port: #vncserver -kill :1
           #vncserver -kill :2
Check port: netstat 5900




Although we can use SSH to connect remotely through a character interface Operating Linux, but it is very inconvenient for more familiar with graphics, so it is necessary to open the remote desktop of Linux. At present, there are two popular methods: XDM (X display manager) scheme and VNC scheme, and I personally prefer the VNC scheme. One is that the VNC scheme is relatively easy to configure, and the other is that the VNC scheme supports multiple connection methods. For example, accessing the Linux desktop through a browser eliminates the need to install a client.

Next, enter the specific configuration instructions:

1. Confirm and install VNCSERVER.

1. First confirm whether your server is configured with VNCSERVER, you can type the following command on the command line to check:

[root@localhost: ~]#rpm -qa |grep vnc

vnc-server-4.1.2-14.el5 #Return to VNCSEVER The server side release states that you have VNCSERVER installed.

2. If VNCSEVER is not installed, find the installation package from the CD and install it.

First, mount the CD (also called decompression) to a directory. Here, the rhel5-64 directory is created under /var/ftp/pub/

mount -o loop rhel-server-5.3-x86_64-dvd.iso /var/ftp/pub/rhel5-64/

Then find vnc-server-4.1.2 in the /var/ftp/pub/rhel5-64/Server directory -14.el5.x86_64.rpm installation package, use RPM command to install directly;

rpm -ivh vnc-server-4.1.2-14.el5.x86_64.rpm


Second, start configuring VNCSERVER

1, start VNCSERVER, start VNCSERVER for the first time You will be prompted to enter a password, which is divided into administrator accounts and ordinary accounts, and the startup methods are slightly different.

Administrator:

[root@localhost /]# vncserver

You will require a password to access your desktops.

Password: 123456 #Enter the vnc connection password

Verify: 123456 #Confirm the vnc password

xauth: creating new authority file /root/.Xauthority

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


normal user:

[root@localhost /]#su ceboy #ceboy is username
[ceboy@localhost /] $ vncserver

You will require a password to access your desktops.

Password: 123456 #Enter the vnc connection password

Verify: 123456 #Confirm the vnc password

xauth: creating new authority file /home/ceboy/.Xauthority

New 'localhost.localdomain:2 (ceboy) ' desktop is localhost.localdomain:2

Creating default startup script /home/ceboy/.vnc/xstartup
Starting applications specified in /home/ceboy/.vnc/xstartup
Log file is /home/ceboy/.vnc/localhost.localdomain:2 .log

# Note here: each user can start his own VNCSERVER remote desktop, and each user can start multiple VNCSERVER remote desktops, which are identified by ip plus port numbers: ip:1, ip:2, ip:3, Different, using the same port will automatically log out the other logged in users. In addition, most of the configuration files and log files of VNCSERVER are in the .vnc directory under the user's home directory.

Users can customize the startup number such as:

[ceboy@localhost /]$ vncserver :2 #Note: There must be a space in front of 2.
A VNC server is already running as: 2

Third, related desktop configuration, RedHat Linux supports two graphics modes: KDE mode and gnome mode.

1. What graphical mode is your RH using? This can only be known by logging in to the graphical interface, or by listing all currently running programs through the ps -A command to see if there are KDE or gnome words to judge.

If you are a gnome desktop, then you need to modify the /root/.vnc/xstartup configuration file.

[root@localhost .vnc]# vi xstartup

#!/bin/sh

# Uncomment the following two lines for normal desktop:

# unset SESSION_MANAGER #Uncomment this line

# exec /etc/X11/xinit/xinitrc #This line remove the comment

[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup

[ -r $HOME/.Xresources ] && xrdb $HOME/ .Xresources

xsetroot -solid grey

vncconfig -iconic &

xterm -geometry 80×24+10 +10 -ls -title "$VNCDESKTOP Desktop" &

gnome-session gnome #Add this sentence to use the gnome desktop environment

twm when connecting &

after the settings are modified, it is best to restart the system once, otherwise the settings will not take effect. The method I use is to kill the VNCSERVER process and re-run VNCSERVER.

[root@localhost .vnc]#vncserver -kill :1 #Here you need to correspond to the port number when you start vncserver.
[root@localhost .vnc]#vncserver:1 #Restart VNCSERVER, note: 1 must be preceded by a space.

2. Set user information and resolution.

[root@localhost: ~]#vi /etc/sysconfig/vncservers

# The VNCSERVERS variable is a list of display:user pairs.

#

# Uncomment the lines below to start a VNC server on display :2

# as my ‘myusername’ (adjust this to your own). You will also

# need to set a VNC password; run ‘man vncpasswd’ to see how

# to do that.

#

# DO NOT RUN THIS SERVICE if your local area network is

# untrusted! For a secure way of using VNC, see

# <URL:http://www.uk.research.att.com/archive/vnc/sshvnc.html >.

# Use “-nolisten tcp” to prevent X connections to your VNC server via TCP.

# Use “-nohttpd” to prevent web-based VNC clients connecting.

# Use “-localhost” to prevent remote VNC clients connecting except when

# doing so through a secure tunnel. See the “-via” option in the

# `man vncviewer’ manual page.

VNCSERVERS=”1:root 2:ceboy” #Add users here, generally only one 1:root will do.

VNCSERVERARGS[1]=”-geometry 800×600 -nolisten tcp -nohttpd -localhost”
VNCSERVERARGS[2]=”-geometry 1024×768 -nolisten tcp -nohttpd -localhost” #Note

: The above are the root and ceboy settings respectively The resolution of each user, note that it is distinguished by the port number.

In addition, you can temporarily modify the resolution and color depth through the command line. This method will be lost after restarting. It is temporarily unavailable here. The command is as follows:

[root@localhost: ~]#vncserver -geometry 800×600 #Set the vncserver Resolution  

[root@localhost: ~]#vncserver -depth 16 #Set the color depth

of vncserver At this point, the configuration of the VNCSERVER server is completed.

Fourth, the client connection and use.

1. Access method
a. Under linux, just run the vncviewer command. The server address is written in the form of 192.168.1.11:1
b. Under windows, just run the windows version of vncviewer. The usage is similar to that under linux.
c. Use a browser (platform independent) to implement as a java applet, and start it in the form of http://192.168.1.11:5801 (vnc port starts from 5800 and so on, generally 5800, 5900)

The following is Some common sense:

2. Change the password and

run vncpasswd

. 3. Stop vncserver

#vncserver -kill :1
#vncserver -kill :2

Note that vncserver can only be closed by the user who started it, even root cannot be closed by other users vncserver, you can only use the kill command to violently kill the process.

4. Stability setting

vncserver By default, when multiple clients connect to the display port of the same vncserver, the old connection of the vncserver port is used for the new connection. You can reject the new connection request through -dontdisconnect and keep the old connection.

5. Multiple clients can be connected to the same monitor

#vncserver -alwaysshared

6, restart the service

service vncserver restart

7, let the system start VNCSERVER automatically.

Use the VNC connection to log in to the RedHat Linux graphical interface, click "System" - "Management" - "Server Settings" - "Services", find VNCSERVER in "Background Services", check it, and click Save.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326781593&siteId=291194637