Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install, configure and use VNC Services in Linux Environment

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article will explain in detail how to install, configure and use VNC services in the Linux environment. The content of the article is of high quality, so the editor will share it with you for reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.

As a DBA, in the process of creating an Oracle database, you usually use dbca and netca visualization to build the database and create monitoring (if you use a script to build the database). If you are in good health, you can probably complete the process of creating the database in the shivering computer room. Because I am sensitive to cold and do not want to exercise in this way, I prefer to taste the fragrance of coffee in a comfortable room. By the way, through the relatively boring process of database installation and configuration, So, graphical operating tools are essential. The most popular graphical operating software in the Linux operating system is VNC. I have completed this detailed article for the purpose of summary, sharing and reminding. I hope you like it.

1. Confirm that VNC is installed

By default, the Red Hat Enterprise Linux installer installs the VNC service on the system.

Confirm that the 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 find the VNC service RPM installation package vnc-server-4.1.2-9.el5.x86_64.rpm in the Server directory of the operating system installation disk, with the following installation command

Rpm-ivh / mnt/Server/vnc-server-4.1.2-9.el5.x86_64.rpm

two。 Start the VNC service

Use the vncserver command to start the VNC service in the format of "vncserver: desktop number", where the "desktop number" is represented by "number". Each user needs to occupy one desktop in a row.

An example of starting a desktop numbered 1 is as follows

[root@testdb ~] # vncserver: 1

You will 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 the password, which is encrypted and saved in the .vnc subdirectory (/ root/.vnc/passwd) under the user's home directory; at the same time, the xstartup configuration file (/ root/.vnc/xstartup) is automatically established for the user in the .vnc subdirectory under the user's home directory, and the configuration information in this file will be read every time you start the VND service.

There is also a "testdb:1.pid" file in the BTW:/root/.vnc/ directory, which records the process number corresponding to the acquired operating system after starting VNC, which is used to accurately locate the process number when stopping the VNC service.

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. VNC uses the TCP port starting from 5900, and the corresponding relationship is as follows

The desktop number is "1"-the port number is 5901

The desktop number is "2"-the port number is 5902

The desktop number is "3"-the port number is 5903

……

Java-based VNC client program Web service TCP port starts from 5800, which is also related to the desktop number, and the corresponding relationship is as follows

The desktop number is "1"-the port number is 5801

The desktop number is "2"-the port number is 5802

The desktop number is "3"-the port number is 5803

……

Based on the above description, if Linux enables the firewall function, you need to open the corresponding port manually. Take the corresponding port with desktop number "1" 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 the VNC service

The first method is to use VNC Viewer software to log in and test. The operation procedure is as follows.

Start the VNC Viewer software-- > Server enter "144.194.192.183 OK"-- > Click "OK"-> Password enter the login password-- > Click "OK" to log in to the X-Window graphical desktop environment-- > Test succeeded

The second method is to log in and test using a Web browser (such as Firefox,IE,Safari). The procedure is as follows

Enter http://144.194.192.183:5801/-- > in the address bar to display the VNC viewer for Java interface (this tool is a VNC client program written in Java). At the same time, jump out of the VNC viewer dialog box, enter "144.194.192.183VNC viewer 1" at Server, click "OK"-- > Password enter login password-- > click "OK" to log in to the X-Window graphical desktop environment-- > Test succeeded.

(note: VNC viewer for Java requires JRE support. If the page cannot be displayed, JRE is not installed. You can download the latest JRE here to install it.)

5. Configure the VNC graphical desktop environment to be KDE or GNOME desktop environment

If you are configured according to my above method, the effect after logging on to the desktop is very simple, and there is only one Shell available, why? How can I see a lovely and beautiful KDE or GNOME desktop environment? The answer is as follows

The reason why it is so ugly is that the VNC service uses the twm graphical desktop environment by default, which can be modified in VNC's configuration file xstartup. Take a look at this configuration file first.

[root@testdb ~] # vi / 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 &

Change the last line of the xstartup file to "startkde &", and then restart the vncserver service to log in to the KDE desktop environment

Change the last line of the 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 start VNC for multiple desktops using the following method

Vncserver: 1

Vncserver: 2

Vncserver: 3

……

However, this manual startup method will fail after the server restarts. Therefore, here is how to let the system automatically manage the VNC of multiple desktops by adding the information that needs to be managed automatically to the / etc/sysconfig/vncservers configuration file. Take Desktop 1 as root user Desktop 2 as an example to configure oracle users as follows:

Format: VNCSERVERS= "Desktop number: user name used Desktop number: user name used"

[root@testdb ~] # vi / etc/sysconfig/vncservers

VNCSERVERS= "1:root 2:oracle"

VNCSERVERARGS [1] = "- geometry 1024x768"

VNCSERVERARGS [2] = "- geometry 1024x768"

7. Change the password for VNC access

Use the command vncpasswd to modify the VNC passwords of different users. It is important to note that if the VNC of different users is configured, they need to be modified separately. For example, in my experiment, root users 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 the VNC service

1) start the 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 the 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 the VNC service to load automatically when the system starts

The first method: use the "ntsysv" command to start the graphical service configuration program, add an asterisk before the vncserver service, click OK, and the configuration is complete.

The second method: use "chkconfig" to operate in command line mode, and the command is as follows (self-service man to predict the detailed use of chkconfig)

[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

9. Summary

The detailed configuration method of VNC has been written here, I hope it can be helpful to everyone. VNC for remote call graphical interface is very light and convenient, make good use of it!

So much for sharing on how to install, configure and use VNC services in the Linux environment. I hope the above can be helpful to you and learn more. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report