Linux system brings performance convenience to developers, but loses the convenience of window system interface management. The following describes how to implement interface operations on Linux. (CENTOS as an example)

This article explains how to install VNC service in centos and use VNC Viewer connection.

VNC SERVER installation:

  1. Run the following command as root
yum install tigervnc-server
Copy the code
  1. Disabling the Firewall
systemctl stop firewalld.service
systemctl disable firewalld.service
Copy the code
  1. Run the service
which vncserver
Copy the code

Results: / usr/bin/vncserver

/usr/bin/vncserver
Copy the code

2. Disable the firewall

VNC SERVER configuration:

  1. Create a new profile, using the first connection as an example (you can also open multiple connections at the same time, just change the number. Windows-like multi-user connection), as follows:
cp /lib/systemd/system/[email protected] /lib/systemd/system/vncserver@:1.service
cp /lib/systemd/system/[email protected] /lib/systemd/system/vncserver@:2.service
Copy the code
  1. View the configuration created above:
ls /lib/systemd/system
Copy the code

  1. Edit the configuration file/lib/systemd/system/vncserver @ : 1. The service. Use the username you want to connect to instead. It is generally recommended that you connect first to the root user.
vi /lib/systemd/system/vncserver@:1.service
Copy the code
[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target
[Service]
Type=forking
# Clean any existing files in /tmp/.X11-unix environment
ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
ExecStart=/sbin/runuser -l root -c "/usr/bin/vncserver %i"
PIDFile=/root/.vnc/%H%i.pid
ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
Copy the code

Save update VNC configuration:

  1. save
systemctl daemon-reload 
Copy the code
  1. Example Set the vNCServer password
vncpasswd root
Copy the code

3. Start and stop the VNC Server

systemctl start vncserver@:1.service
systemctl stop vncserver@:1.service
Copy the code

4. View the VNC running status

systemctl status vncserver@:1.service
Copy the code

5. Automatically start after startup

systemctl enable vncserver@:1.service
Copy the code
  1. Check the VNC port number
ss -tulpn|grep vnc
Copy the code

  

Common problems encountered when starting VNC Server:

Job for vncserver@:1.service failed because the control process exited with error code. See "systemctl status vncserver@:1.service" and "journalctl -xe" for details.
[root@localhost jesse]# vi /lib/systemd/system/vncserver@:2.service
Copy the code

Change Type in vncserver@:1.service to simple

To perform

systemctl daemon-reload 
Copy the code

VNC viewer connection

1. Download and install VNC Viewer

www.realvnc.com/en/connect/…

  1. configuration

Note: Port number 5901 is the first connection. The default is 590+ connection number. You can manually change the port.