Reference: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/3038
1. Install: tigervnc
sudo apt install tigervnc-standalone-server tigervnc-xorg-extension
2. create file: vncserver xwindow start script
sudo mkdir /etc/vnc
sudo vi /etc/vnc/xstartup
#!/bin/sh
test x"$SHELL" = x"" && SHELL=/bin/bash
test x"$1" = x"" && set -- default
vncconfig -iconic &
"$SHELL" -l <<EOF
export XDG_SESSION_TYPE=x11
dbus-launch --exit-with-session gnome-session
exec /etc/X11/Xsession "$@"
EOF
vncserver -kill $DISPLAY
3. create file: user window start script:
mv ~/.vnc/xstartup ~/.vnc/xstartup.old
vi ~/.vnc/xstartup
#!/bin/sh
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
vncconfig -iconic &
dbus-launch --exit-with-session gnome-session &
4 set run permission:
sudo chmod u+x /etc/vnc/xstartup
chmod u+x ~/.vnc/xstartup
5. create file: system service script
sudo vi /etc/init.d/vncserver
#!/bin/bash
### BEGIN INIT INFO
# Provides: vncserver
# Required-Start: networking
# Required-Stop: networking
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
### END INIT INFO
PATH=$PATH:/usr/bin/
USER="tom"
BIN_PATH=/usr/bin
VNC_SERVER=vncserver
DISPLAY="1"
DEPTH="16"
GEOMETRY="1920x1200"
OPTIONS="-localhost no -depth ${DEPTH} -geometry ${GEOMETRY} :${DISPLAY}"
. /lib/lsb/init-functions
case "$1" in
start)
log_action_begin_msg "Starting vncserver for user '${USER}' on localhost:${DISPLAY}"
su - ${USER} -c "${BIN_PATH}/${VNC_SERVER} ${OPTIONS}"
;;
stop)
log_action_begin_msg "Stoping vncserver for user '${USER}' on localhost:${DISPLAY}"
su - ${USER} -c "${BIN_PATH}/${VNC_SERVER} -kill :${DISPLAY}"
;;
restart)
$0 stop
$0 start
;;
esac
exit 0
6. set start-up service & start vncserver
sudo systemctl enable vncserver
sudo systemctl start vncserver
- connect vnc-server: [address]:1 or [address]:5901