Linux study notes - configure VNC

Install VNC

Install a desktop environment

sudo apt install xfce4 xfce4-goodies --fix-missing

install vncserver

apt install tightvncserver

Start the vncserver service and initialize

vncserver

Enter the command to run, 1920*1080 refers to the resolution, 1 refers to the port number

vncserver -geometry 1920x1080 :1


 

Solution if a white screen appears

In the vnc client (noVNC/vncviewer), the remote link IP: 1
but after entering the password, a gray screen is displayed and the mouse is an X.
This is because the vncserver cannot find the specified graphical tool in the Ubuntu system.

At this time, you need to download the graphical tool in Ubuntu

sudo apt-get install gnome-panel gnome-settings-daemon metacity nautilus gnome-terminal --fix-missing

Then configure the parameters of vncserver

Close the running vncserver desktop, 1 refers to the port number

vncserver -kill :1

备份原来的配置文件

mv ~/.vnc/xstartup ~/.vnc/xstartup.bak

编辑新的配置文件

vim ~/.vnc/xstartup

Make sure your visual interface is open, you have entered it before vncserver :portnum or vncserver -geometry 1920x1080 :portnum
then entered it in sequence
cd .vnc 
ls
vi xstatrup


After inputting, click Enterthe key

After entering, xstatrupreplace the file inside with the following content

#!/bin/sh

xrdb $HOME/.Xresources
xsetroot -solid grey
x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
#x-window-manager &
# Fix to make GNOME work
export XKL_XMODMAP_DISABLE=1
/etc/X11/Xsession
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
gnome-panel &
gnmoe-settings-daemon &
metacity &
nautilus &
gnome-terminal &
~

When replacing, remember to switch to insert (that is, see INSERT displayed in the lower left corner) mode
[switching method: Esc —> a]
and then save and exit (method: click Esc —> : ----> wq----> enter )

After exiting and restarting,
enter in sequence

vncserver -kill :1

This is to close the interface you opened before, 1 is the original port number

vncserver -geometry 1920x1080 :1

common problem

Unable to download  http://cn.archive.ubuntu.com/ubuntu/.... The checksum does not match

sudo vim /etc/apt/sources.list


Then
http://cn.archive.ubuntu.com/ubuntu/
replace in the file with
http://mirrors.163.com/ubuntu
or
http://mirrors.sohu.com/ubuntu
and execute

sudo apt-get update

Update it.
If similar problems still occur, it is recommended to try more replacements. Some use 163, and some use sohu

Guess you like

Origin blog.csdn.net/DIRI23/article/details/125240651