After install VNC server on CentOS, when i run command # systemctl start vncserver@:1.service to start it, i meet bellow error message.
# systemctl start vncserver@:1.service 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.
I search google for the resolution, finally i find below steps.
- First login to linux OS with the user which you use in /etc/systemd/system/vncserver@:1.service file.
- Verify file /usr/bin/vncserver exist and execute it in the terminal.
[happyzhaosong@MiWiFi-R4A-srv ~]$ /usr/bin/vncserver You will require a password to access your desktops. Password: Verify: Would you like to enter a view-only password (y/n)? y Password: Verify: xauth: file /home/happyzhaosong/.Xauthority does not exist New 'MiWiFi-R4A-srv:3 (happyzhaosong)' desktop is MiWiFi-R4A-srv:3 Creating default startup script /home/happyzhaosong/.vnc/xstartup Creating default config /home/happyzhaosong/.vnc/config Starting applications specified in /home/happyzhaosong/.vnc/xstartup Log file is /home/happyzhaosong/.vnc/MiWiFi-R4A-srv:3.log
- Then it will create /home/happyzhaosong/.vnc/xstartup file.
- Edit file /home/happyzhaosong/.vnc/xstartup, add # at the beginning of line vncserver -kill $DISPLAY to remove it.
if [ -e /usr/bin/gnome-session -o -e /usr/bin/startkde ]; then # vncserver -kill $DISPLAY fi
- If above method do not take effect, you can run command # rm -rf /tmp/.X11-unix/ with root user, and then reboot system.
# rm -rf /tmp/.X11-unix/
- If above method do not take effect, you can edit file /etc/systemd/system/vncserver@:1.service and change Service —> Type from forking to simple.
# vim /etc/systemd/system/vncserver@:1.service # Edit Service section, change Type=forking to Type=simple. [Service] Type=forking #Type=simple
- Then run command # systemctl daemon-reload to update systemctl.
# systemctl daemon-reload