Start from scratch: Detailed explanation of the installation and setup of VNC on Ubuntu
On the Ubuntu operating system, VNC (Virtual Network Computing) is a remote desktop protocol that can Achieve remote access and control of Ubuntu desktop through network connection. This article will detail the steps to install and set up VNC on Ubuntu, including specific code examples.
Step one: Install VNC server
sudo apt-get update
sudo apt-get install vnc4server
vncserver
will prompt Enter a password. This password will be used as the password to access the VNC server. Be sure to remember it.
Step 2: Configure VNC server
vncserver -kill :1
here ":1" represents the display number of the VNC server. If your VNC server is on another display, you can modify it accordingly.
nano ~/.vnc/xstartup
In the open file, copy and paste the following into the file:
xrdb $HOME/.Xresources
startxfce4 &
Save and exit the editor.
Step 3: Configure the startup script of the VNC server
nano ~/.vnc/vncserver_start.sh
In the open file, copy and paste the following into the file:
PATH="$PATH:/usr/bin/"
DISPLAY="1"
DEPTH="16"
GEOMETRY="1024x768"
OPTIONS="-depth ${DEPTH} - geometry ${GEOMETRY} :${DISPLAY}"
case "$1" in
start)
/usr/bin/vncserver ${OPTIONS} ;;
stop)
/usr/bin/vncserver -kill :${DISPLAY} ;;
*)
echo "Usage: /etc/init.d/vncserver {start|stop}" exit 1 ;;
esac
exit 0
Save and exit the editor.
chmod x ~/.vnc/vncserver_start.sh
Step 4: Configuration Self-starting of VNC server
sudo nano /etc /systemd/system/vncserver.service
In the opened file, copy and paste the following into the file:
[Unit]
Description=VNC Server
After= syslog.target network.target
[Service]
Type=forking
User=your_username
ExecStart=/home/your_username/.vnc/vncserver_start.sh start
ExecStop=/ home/your_username/.vnc/vncserver_start.sh stop
Restart=on-failure
RestartSec=2
[Install]
WantedBy=multi-user.target
Please replace "your_username" with your username.
Save and exit the editor.
sudo systemctl daemon-reload
sudo systemctl enable vncserver.service
Step 5: Start and connect the VNC server
sudo systemctl start vncserver.service
Step 6: Optimize the performance of the VNC server
If you are not satisfied with the performance of the VNC server, you can try to optimize the settings to improve the speed and smoothness of remote access and control.
nano ~/.vnc/config
In the file, find the following line and cancel Comment (remove the preceding "#" symbol):
Then modify these behaviors:
geometry= 1920x1080
Save and exit the editor.
vncserver -kill :1
vncserver
The above are the detailed steps for installing and setting up VNC on Ubuntu. Using VNC server, you can easily access and control the Ubuntu desktop remotely, which is convenient and practical. Code examples also help you better understand each step. Hope this article is helpful to you!
The above is the detailed content of Starting from Scratch: Detailed Installation and Setup of VNC on Ubuntu. For more information, please follow other related articles on the PHP Chinese website!