前言
每次等vncviewer都有点问题,这次更是。在此记录之。
1 场景
先输入:vncserver :1
得到:
Warning: dale:1 is taken because of /tmp/.X1-lock
Remove this file if there is no X server dale:1
A VNC server is already running as :1
根据我依稀记得的经验,我输入了sudo rm /tmp/.X1-lock
,然后干脆输入了sudo rm -rf /tmp/
,然后再运行vncserver :1
,此时:
New ‘dale:1 (dale)’ desktop is dale:1
Starting applications specified in /home/dale/.vnc/xstartup
Log file is /home/dale/.vnc/dale:1.log
然而,无论如何,都会显示:
2 查找原因
输入:cat /home/dale/.vnc/dale:1.log
显示:
xsetroot: unable to open display ‘dale:1’ /home/dale/.vnc/xstartup:
12: /home/dale/.vnc/xstartup: gnome-settings-daemon: not found
vncconfig: unable to open display “dale:1” Unable to init server:
Could not connect: Connection refused(gnome-panel:696): Gtk-WARNING **: 05:20:26.023: cannot open display:
dale:1(metacity:698): metacity-CRITICAL **: 05:20:26.029: Unable to open X
display dale:1 Unable to init server: Could not connect: Connection
refused(nautilus:699): Gtk-WARNING **: 05:20:26.164: cannot open display:
dale:1 Unable to init server: Could not connect: Connection refusedFailed to parse arguments: Cannot open display:
Fatal server error: Could not create lock file in /tmp/.tX1-lock
输入:sudo apt-get update
显示:
Hit:1 http://mirrors.aliyun.com/ubuntu bionic InRelease Err:1
http://mirrors.aliyun.com/ubuntu bionic InRelease Couldn’t create
temporary file /tmp/apt.conf.mI7q6Z for passing config to apt-key
Get:2 http://mirrors.aliyun.com/ubuntu bionic-security InRelease [88.7
kB] Err:2 http://mirrors.aliyun.com/ubuntu bionic-security InRelease
Couldn’t create temporary file /tmp/apt.conf.XPUFxe for passing config
to apt-key Get:3 http://mirrors.aliyun.com/ubuntu bionic-updates
InRelease [88.7 kB] Err:3 http://mirrors.aliyun.com/ubuntu
bionic-updates InRelease Couldn’t create temporary file
/tmp/apt.conf.NLAJar for passing config to apt-key Get:4
http://mirrors.aliyun.com/ubuntu bionic-proposed InRelease [242 kB]
Err:4 http://mirrors.aliyun.com/ubuntu bionic-proposed InRelease
Couldn’t create temporary file /tmp/apt.conf.gs8ANC for passing config
to apt-key Get:5 http://mirrors.aliyun.com/ubuntu bionic-backports
InRelease [74.6 kB] Err:5 http://mirrors.aliyun.com/ubuntu
bionic-backports InRelease Couldn’t create temporary file
/tmp/apt.conf.ztFN1M for passing config to apt-key
3 解决方案
根据关键字:“Couldn’t create temporary file /tmp/apt.conf.XPUFxe for passing config”搜索即可。
解决方案:
1)sudo mkdir /tmp
2)sudo chmod 777 /tmp
3)此时再运行vnc4server
,一切顺利,打开。