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
So, i have a solution! Install x11vnc first. Then do this:
1. Create a script:
sudo nano /usr/local/bin/vnc-gdm
It looks like this:
#!/bin/bash
id=$(id -u)
x11vnc -loop -rfbport 5900 -forever -bg -xkb -noxrecord -noxfixes -noxdamage -many -create -display :0 -auth /run/user/$id/gdm/Xauthority
2. Make the script executable:
sudo chmod +x /usr/local/bin/vnc-gdm
3. Create x11vnc for gdm:
su -c ‘cat > /usr/share/gdm/greeter/autostart/vnc-gdm.desktop < /etc/xdg/autostart/vnc-users.desktop << EOF
[Desktop Entry]
Name=VNC for all users
Type=Application
Exec=x11vnc -loop -rfbport 5900 -repeat -many -noxkb -shared -noxdamage -find -auth guess
Hidden=false
EOF'
Reboot, connect via VNC, and… it works! Thats it. Not that hard. But doing research and coming up with the solution was rly hard. Thanks to my good bro for helping me out. This solution isnt ideal but it satisfies all my needs, so i hope it will be usefull for someone just like it was for me.
Appologies. Here are working files:
file /usr/share/gdm/greeter/autostart/vnc-gdm.desktop
looks like this:
[Desktop Entry]
Name=VNC for GDM
Type=Application
Exec=vnc-gdm
Hidden=false
file /etc/xdg/autostart/vnc-users.desktop
looks like this:
[Desktop Entry]
Name=VNC for all users
Type=Application
Exec=x11vnc -loop -rfbport 5900 -repeat -many -noxkb -shared -noxdamage -find -auth guess
Hidden=false
/usr/local/bin/vnc-gdm script from my first comment works
Oh, for crying out loud. Is there a single linux tutorial anywhere on the internet that actually works?
“Can’t exec ‘/root/.vnc/xstartup’: Permission denied”
But of course you don’t mention this at all, because like every single Linux tutorial in the entire world, you just assume it works and leave us hanging high end dry when it doesn’t actually work and spits out errors instead (which is ALWAYS). What a damn waste of time. Take this broken tutorial off the internet before you waste anybody else’s time.
Same bro I feel you
Btw have you found any working instruction regarding vncserver?
Oh Thank you so much.
In my case it was the fork->simple thing.