Home > Java > javaTutorial > Simple and practical: Ubuntu VNC installation and setup tutorial

Simple and practical: Ubuntu VNC installation and setup tutorial

WBOY
Release: 2023-12-29 11:20:41
Original
1888 people have browsed it

轻松上手:Ubuntu VNC安装和配置指南

Easy to get started: Ubuntu VNC installation and configuration guide

Introduction: Ubuntu is a powerful and popular operating system, and VNC is a remote desktop Protocol that enables users to control remote computers over a network. This article will take you through the installation and configuration process of VNC in Ubuntu system in detail, including specific code examples.

Step 1: Install VNC Server

  1. Open Terminal and enter the following command to install VNC Server:

    sudo apt-get update
    sudo apt-get install vnc4server
    Copy after login
  2. After the installation is complete, enter the following command to start VNC Server and set a password:

    vncserver
    Copy after login

Step 2: Configure VNC Server

  1. Use the following command to edit the configuration file of VNC Server:

    nano ~/.vnc/xstartup
    Copy after login
  2. Add the following content at the end of the file to specify the desktop environment where VNC Server runs:

    #!/bin/sh
    export XKL_XMODMAP_DISABLE=1
    unset SESSION_MANAGER
    unset DBUS_SESSION_BUS_ADDRESS
    
    [ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
    [ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
    xsetroot -solid grey
    vncconfig -iconic &
    x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
    gnome-session &
    Copy after login
  3. Save and exit the configuration file.

Step 3: Enable VNC Server auto-start

  1. Enter the following command to create a new system service (service) file:

    sudo nano /etc/systemd/system/vncserver@.service
    Copy after login
  2. Enter the following into the opened file:

    [Unit]
    Description=VNC Server at %i
    After=syslog.target network.target
    
    [Service]
    Type=forking
    User=<YOUR_USERNAME>
    ExecStartPre=-/usr/bin/vncserver -kill :%i > /dev/null 2>&1
    ExecStart=/usr/bin/vncserver -depth 24 -geometry 1280x800 :%i
    ExecStop=/usr/bin/vncserver -kill :%i
    
    [Install]
    WantedBy=multi-user.target
    Copy after login

    Be sure to replace <YOUR_USERNAME> with your actual username.

  3. Save and exit the file.
  4. Enter the following command to let the system load the new service file:

    sudo systemctl daemon-reload
    Copy after login
  5. Enter the following command to start the VNC Server and set up auto-start:

    sudo systemctl start vncserver@1
    sudo systemctl enable vncserver@1
    Copy after login

Step 4: Configure the firewall

If the firewall (UFW) is enabled in your system, you need to open the port used by the VNC Server.

  1. Enter the following command to allow incoming connection traffic:

    sudo ufw allow 5901
    Copy after login

Step 5: Connect to VNC Server

Now, you can use any VNC Viewer software to connect to the VNC Server. During the connection process, you need to enter the server's IP address and port number.

  1. In the VNC Viewer software, enter the server’s IP address and port number (for example: 192.168.0.100:5901).
  2. Enter the VNC password set previously.
  3. Click the "Connect" button and wait for the connection to be successful.

Conclusion:

Through the installation and configuration guide provided in this article, you can easily deploy VNC Server on the Ubuntu system and connect to the remote desktop through the network. Now, you can remotely control the Ubuntu system and enjoy an efficient and convenient operating experience whether at home or in the office. Wish you happy using it!

The above is the detailed content of Simple and practical: Ubuntu VNC installation and setup tutorial. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template