指定用户开启自启vncserver
[root@localhost ags_pkg]# cat /etc/systemd/system/vncserver@:2.service
[Unit]
Description=Remote desktop service(vnc)
After=syslog.target network.target
[Service]
Type=forking
ExecStartPre=sh -c ‘/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :’
ExecStart=/sbin/runuser -l hollysys -c “/usr/bin/vncserver %i -geometry 1280x1024”
PIDFile=/home/hollysys/.vnc/%H%i.pid
ExecStop=/bin/sh -c ‘/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :’
[Install]
WantedBy=multi-user.target
#systemctl start vncserver@:2.service
#systemctl enable vncserver@:2.service
#手动启动 指定用户
#/sbin/runuser -l hollysys -c “/usr/bin/vncserver :2 -geometry 1280x1024”
或
普通用户ssh后,直接vncserver :1
以上两种实际启动的桌面环境有差异,如pkexec提权窗口是否是UI还是命令行会有差异