我更改好vncserver配置文件后,以
su user
```创建了一个vnc用户,在此之前配置文件中设置是这样的
[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target
[Service]
Type=simple
#Clean any existing files in /tmp/.X11-unix environment
ExecStartPre=/bin/sh -c ‘/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :’
ExecStart=/usr/sbin/runuser -l user -c “/usr/bin/vncserver %i”
PIDFile=/home/user/.vnc/%H%i.pid
ExecStop=/bin/sh -c ‘/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :’
[Install]
WantedBy=multi-user.target
两个位置我都改的user
在启动vncserver@1时候没报错,后面我查看状态显示启动失败的,琢磨半天没找到原因
[roo@hostlive~]# ll /home/user/.vnc/
total 16
-rw-r--r-- 1 user user 332 Aug 31 15:48 config
-rw-rw-r-- 1 user user 626 Aug31 15:48 hog
-rW-------1 user user16 Aug 31 15:42 passd
-rwxr-xr-x 1 user user 540 Sep 2 10:23 xstartup
[root@hostlive~]# systemctl start vncserver@:1.service
Warning: vncserver@:1.service changed on disk. Run 'systemctl daemon-reload' to reload units.
[root@hostlive~]# systemctl daemon-reload
[root@hostlive~]# systemctl start vncserver@:1.service
[root@hostlive ~]# systemctl status vncserver@:1.service
• vncserver@:1.service- Remote desktop service (VNC)
Loaded: loaded (/etc/systemd/system/vncserver@:.service;enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Fri 2022-09-02 12:47:58 CST; 46s ago
Process: 3323 ExecStart=/usr/sbin/runuser
-1 user -c /usr/bin/vncserver %1 (code=exited, status=98)
Process:3315 ExecStartPre=/bin/sh-C/usr/bin/vncserver-kill %i > /dev/null 2>&1|| : (code=exited, status=0/SUCCESS)
Main PID: 3323 (code=exited, status=98)
Sep 02 12:47:58 hostlive system[1]: Starting Remote deskto..
Sep 02 12:47:58 hostlive
systemd[1]: Started Remote desktop.
Sep 02 12:47:58 hostlive
systemd[1]: vncserver@:l.service:
Sep 02 12:47:58 hostlive system[1]: Unit vncserver@:l.serv.
Sep 02 12:47:58 hostlive systemd[1]:vncserver@:l-servicef...
Hint: Some lines were ellipsized, use-I to show in full.
[root@hostlive~]#****
```