systemctl .service file for vncserver under CentOS 7.7

People can do almost everything vis ssh under Linux, no exception for CentOS. But in some cases, using a X Windows improves efficiency greatly.

Tiger VNC server is a good server end package for VNC protocal under CentOS.
Tonight, just an hour ago, I encountered a disaster due to an unprofessional systemctl script privided by Tiger VNC server devolopers.

I’m tired so I shall not record the details.
If you are suffering problems while you are deploying autostart VNC server via systemctl, like:

  1. New main PID <pid> does not belong to service, and PID file is not owned by root. Refusing.;
  2. Enabled multiple vnc ports for no reason;
  3. Can not input password when the vnc client in locked screen;

Just try a .service file as fllow:
Do !NOT! forget to change USERNAME to your own user.

Description=Remote desktop service (VNC)


# Clean any existing files in /tmp/.X11-unix environment
ExecStartPre=/sbin/runuser -l <USERNAME> -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
ExecStart=/sbin/runuser -l <USERNAME> -c "/usr/bin/vncserver :1"
ExecStartPost=/bin/sh -c '/usr/bin/cat /home/<USERNAME>/.vnc/ > /tmp/'
ExecStop=/sbin/runuser -l <USERNAME> -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'


Unnamed document

Getting 500 Internal error on /admin/application_settings

Gitlab WEB-IDE: Error while loading project data. please try again.

Gogs迁移到Gitlab -- 利用Gitea作为中介完美迁移



  1. 能够完成Gogs的备份;
  2. 能够完成Gogs与Gitea的升级、降级;
  3. 了解Gitea的Access Tokens的使用;
  4. 能够安装Gitlab(或熟悉Gitlab的使用)。

- Read More -



- Read More -