Related configurations of VNC server under Linux system

Time:2021-10-16

Installation:
 

Copy code

The code is as follows:

yum install tigervnc-server

to configure:

(1) Copy profile:
 

Copy code

The code is as follows:

~]# cp <a>/lib/systemd/system/[email protected]</a> \
<a>/etc/systemd/system/ [email protected] [/code</a>] </p>
</strong> [code]
ExecStart=/sbin/runuser -l USER -c “/usr/bin/vncserver %i -geometry 1280×1024”
PIDFile=/home/USER/.vnc/%H%i.pid

Replace user with the user of the VNC service to be used, such as root:
 

Copy code

The code is as follows:

ExecStart=/sbin/runuser -l root -c “/usr/bin/vncserver %i”

If you want to modify the resolution, you can modify the geometry content, and others do not need to be modified.
Then keep the configuration.

(3) Use the systemctl command to force a reread of the configuration file:
 

Copy code

The code is as follows:

~]# systemctl daemon-reload

(4) Configure vncserver password

Copy code

The code is as follows:

vncpasswd

(5) If two users want to use VNC at the same time, they need to configure two profiles:
  vncserver-USER_ [email protected] And vncserver user_ [email protected] , the file content is the same as the configuration method of root user
Then create VNC passwords for two users:
 

Copy code

The code is as follows:

~]$ su – USER_1
~]$ vncpasswd
Password:
Verify:
~]$ su – USER_2
~]$ vncpasswd
Password:
Verify:

(6) Start VNC service

Copy code

The code is as follows:

systemctl start [email protected]:10

To start up, use the following command:
 

Copy code

The code is as follows:

systemctl enable [email protected]:10
ln -s ‘/etc/systemd/system/[email protected]’ \
‘/etc/systemd/system/multi-user.target.wants/[email protected]:10.service’

(7) Close process
 

Copy code

The code is as follows:

systemctl disable [email protected]:display_number.service
systemctl stop [email protected]:display_number.service