个人技术分享

现在win11内嵌了ubuntu系统,我在根据打造基于 VNC 的 Ubuntu 20.04 的远程桌面 配置VNC server时,到了 vncserver :1 这一步,遇到报错:

vncserver: /usr/bin/Xtigervnc did not start up, please look into '/root/.vnc/xxxxx.:1.log' to determine the reason! -1
Killing Xtigervnc process ID 4921... success!

通过查看日志的命令:

cat /root/.vnc/xxxxx.:1.log

定位到报错信息:

_XSERVTransmkdir: Mode of /tmp/.X11-unix should be set to 1777
_XSERVTransSocketCreateListener: failed to bind listener
_XSERVTransSocketUNIXCreateListener: ...SocketCreateListener() failed
_XSERVTransMakeAllCOTSServerListeners: failed to create listener for unix

找到相关博客 vnc issue after reboot,试图手动给 /tmp/.X11-unix 文件开权限:

mkdir /tmp/.X11-unix /tmp/.X11-pipe 2>/dev/null
chmod 1777 /tmp/.X11-unix /tmp/.X11-pipe

但是又遇到了报错:

chmod: changing permissions of '/tmp/.X11-unix': Read-only file system

再找到解决方案 How to make read-only file system writable?

sudo mount -o remount,rw '/tmp/.X11-unix'

然后执行(一定要切到 root 用户下)

mkdir /tmp/.X11-unix /tmp/.X11-pipe 2>/dev/null
chmod 1777 /tmp/.X11-unix /tmp/.X11-pipe

没有报错了

最后再执行

vncserver :1

终于没有报错信息了