1. Method set the root:
1.
cp /lib/systemd/system/[email protected] /etc/systemd/system/vncserver@:1.service
# 2.
1. Edit the file command:
vim /etc/systemd/system/vncserver@\:1.service
2. The document reads as follows:
[Unit] Description=Remote desktop service (VNC) After=syslog.target network.target [Service] Type=forking User=root # Clean any existing files in /tmp/.X11-unix environment ExecStartPre=-/usr/bin/vncserver -kill %i ExecStart=/usr/sbin/runuser -l root -c "/usr/bin/vncserver %i" PIDFile=/root/.vnc/%H%i.pid ExecStop=-/usr/bin/vncserver -kill %i [Install] WantedBy=multi-user.target
3. Set a password vnc, vnc user's password with the system password is not the same, using the password to be required when vnc viewer landing.
Enter the command: vncpasswd
set password
4. Start services, open ports:
1. Run: systemctl daemon-reload # reload This command must be executed, is very important, otherwise not start
2. Run the start command: @ systemctl Start vncserver: 1
3. Set the boot: @ systemctl enable vncserver: 1
4. View startup state command: systemctl status vncserver @: 1
5. Review the service listening port: netstat -lnpt | grep the Xvnc
# According listening port, the port is open, each user will correspond to a port, the first user defaults to port 5901. I have here is the root user
6. firewall ports open:
Command, open ports:
firewall-cmd --add-port=5901/tcp --permanent
Overloading, the command to take effect:
firewall-cmd --reload
References: https: //blog.csdn.net/weixin_41004350/article/details/80805927
https://blog.csdn.net/tpaijojo/article/details/79115095