search
HomeSystem TutorialLINUXUbuntu16.04 uses VNC to connect to the GNOME desktop

Ubuntu16.04 uses VNC to connect to the GNOME desktop

Jun 01, 2024 pm 03:37 PM
linuxlinux tutorialRed Hatlinux systemlinux commandlinux certificationred hat linuxlinux video

Ubuntu16.04 用VNC链接 GNOME 桌面

0x01 Before you begin

Since in some cases, it is necessary to use the graphical interface of remote desktop to connect to the server, so here is a brief introduction on how to install VNC and desktop environment under Ubuntu 16.04 LTS.
Be sure to confirm that your server has 2GB of memory or above to better use the graphical interface, otherwise it will be stuck or even crash.

0x02 Install desktop environment

If you do not install a desktop environment, you will see a gray screen and nothing can be seen after VNC connection.

1. Log in to the server using SSH

Must use root account.

2. Update source and system

Enter the following command:

apt update
apt upgrade -y
3. Install desktop environment

Here we introduce how to install and use the unity desktop, and use gnome 2 for remote connection.

Full installation (not recommended):

apt install ubuntu-desktop gnome-panel gnome-settings-daemon metacity nautilus gnome-terminal -y

Install core components only:
If you do not install additional components such as office, browser, etc., you can use the following command:

apt-get install --no-install-recommends ubuntu-desktop gnome-panel gnome-settings-daemon metacity nautilus gnome-terminal -y
0x03 Install VNC server

1. Enter the following command:

apt install vnc4server -y

2. Test connection:

Note: The user name fills in the user name currently in use, such as root. IP Address Fill in the IP address of the current server.

ssh -L 5901:127.0.0.1:5901 用户名@IP地址或网址

When prompted whether to continue the connection, enter yes. After entering the password, you can log in successfully, which proves that the configuration is correct. Otherwise, you need to check whether the firewall has port 5901 open.

0x04 Configure VNC server
1. Enter the following command:
vncserver :1

The first startup will require you to enter the VNC password twice and the password will not be visible. If you need to change the VNC connection password later, you only need to enter vncpassword.

2. End vncserver

Enter the following command:

vncserver -kill :1
3. Modify the configuration file

1. 修改 ~/.vnc/xstartup,在 x-window-manager & 的后面新增下面这 4 行:

gnome-panel &
gnome-settings-daemon &
metacity &
nautilus &

完整配置文件如下:

 	#!/bin/sh
 	 
 	# Uncomment the following two lines for normal desktop:
 	# unset SESSION_MANAGER
 	# exec /etc/X11/xinit/xinitrc
 	 
 	[ -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" &
 	x-window-manager &

 	gnome-panel &
 	gnome-settings-daemon &
 	metacity &
 	nautilus &

2. 启动 vncserver:

vncserver :1

3. 配置开机启动:

首先输入 crontab 命令。

会提示选择默认的编辑器。推荐使用 vim,选择 vim.basic 就可以了。

Select an editor. To change later, run ‘select-editor’.
1. /bin/ed
2. /bin/nano

@reboot /usr/bin/vncserver :1

提示:
切换英文输入法,按 i 改为插入模式,粘贴完毕后,按 Esc 退出插入模式,然后按 shift 和 : 键,出现“:”后,输入 wq 保存,回车退出。

重启服务器。

reboot
0x05 本地环境安装 VNC 客户端

在 Windows 下,建议使用 TigerVNC,小巧好用。
官方下载地址:http://tigervnc.bphinz.com/nightly/

首次连接会报个错误,直接输入如下命令新建目录即可:

mkdir -p /root/.config/nautilus
0x06 注意事项

在这里要告诉大家的是,Gnome 3 和 Unity 桌面,由于兼容性问题,连上后会什么也无法显示。所以在这里远程桌面连接只能使用 gnome 2。

The above is the detailed content of Ubuntu16.04 uses VNC to connect to the GNOME desktop. For more information, please follow other related articles on the PHP Chinese website!

Statement
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
What are the differences in how Linux and Windows handle user authentication?What are the differences in how Linux and Windows handle user authentication?Apr 30, 2025 am 12:03 AM

The main difference between Linux and Windows in user authentication is that Linux uses PAM modules, while Windows relies on Active Directory and local security policies. 1. Linux provides flexible authentication configurations through PAM, such as passwords, fingerprints, etc. 2. Windows realizes centralized management and enterprise network integration through Active Directory.

How to Install and Run FreeDOS on Linux Using QEMUHow to Install and Run FreeDOS on Linux Using QEMUApr 29, 2025 am 10:36 AM

This guide shows you how to set up the free and open-source DOS-compatible operating system, FreeDOS, within a Linux environment using the QEMU emulator. This allows you to run legacy DOS software and games on modern hardware without needing a separ

How to Install KDE Plasma on Linux Mint 22How to Install KDE Plasma on Linux Mint 22Apr 29, 2025 am 10:10 AM

Linux Mint, an operating system known for its simplicity, stability and ease of use, is popular with users and is especially suitable for beginners. It uses the Cinnamon desktop environment by default, providing a simple and friendly user interface. But if you prefer a different look or need more customization options, you can install other desktop environments such as KDE Plasma. KDE Plasma is a feature-rich, highly customizable and visually excellent desktop environment that provides a modern and stylish user experience. It has a wide range of customization options, advanced window management capabilities and sophisticated aesthetics, perfect for users who want to have a better control over the desktop experience. This guide will guide you step by step to install KDE Pl on Linux Mint 22

How to Reduce High RAM & CPU Usage on LinuxHow to Reduce High RAM & CPU Usage on LinuxApr 29, 2025 am 10:05 AM

Linux system performance optimization: Reduce RAM and CPU usage Linux systems are powerful and efficient, but high RAM and CPU usage can reduce performance, slow down applications, and even cause servers, workstations, or embedded systems to crash. Therefore, optimizing resource usage is crucial for the smooth operation of the system. This guide will explore practical ways to reduce RAM and CPU usage in Linux systems, covering monitoring tools, process management, kernel tuning and system optimization technologies to help you keep your system running efficiently. Identify resource-intensive processes The first step in reducing RAM and CPU usage is to identify which processes consume the most resources. To do this, you can use the following command-line tools: a. Use top

How to Boot Into Single User Mode in AlmaLinux 8/9How to Boot Into Single User Mode in AlmaLinux 8/9Apr 29, 2025 am 09:46 AM

Single User Mode (also known as Rescue Mode) Guide for AlmaLinux 8 and 9 Single-user mode is a streamlined Linux environment that allows system administrators to perform maintenance tasks, troubleshoot problems, and recover from system failures. Single-user mode is especially useful when you need to reset your root password, fix configuration errors, fix corrupt file systems, or investigate system errors that prevent normal startup. As RHEL-based distributions, AlmaLinux 8 and 9 provide an easy way to enter single-user mode via the GRUB boot loader. This guide will explain step by step how to enter single-user mode on AlmaLinux 8 and 9. What is single use

Linux Troubleshooting: 5 Common Problems & How to Fix ThemLinux Troubleshooting: 5 Common Problems & How to Fix ThemApr 29, 2025 am 09:42 AM

Linux systems are known for their power and reliability, but even experienced users will encounter unexpected problems. Whether it is an unexpectedly deleted file, a forgotten root password, or a slow system running, efficient troubleshooting skills are the key to becoming a Linux expert. This guide will introduce common Linux problem solving scenarios and step-by-step solutions that are common among system administrators, developers, and everyday Linux users. Scene 1: Unexpected deletion of important files You accidentally deleted an important file using the rm command and now you need to restore it. Unlike Windows and macOS, Linux does not have a built-in "recycle bin" to store files deleted from the terminal. Recovery options depend on

How to Permanently Change Docker Folder Permissions on LinuxHow to Permanently Change Docker Folder Permissions on LinuxApr 29, 2025 am 09:35 AM

Docker is a powerful tool that allows you to run applications in an isolated environment called containers. However, sometimes you may need to change the permissions of the Docker folder to ensure that your application has access to the necessary files and directories. This article will guide you through the process of permanently changing Docker folder permissions on Linux systems. Understand Docker folder permissions By default, Docker stores its data, including images, containers, and volumes, in specific directories on Linux systems. The most common directory is /var/lib/docker. The permissions of these folders determine who can read, write, or execute the files in it. if

Manage Docker Like a Pro: Install Portainer CE on LinuxManage Docker Like a Pro: Install Portainer CE on LinuxApr 29, 2025 am 09:24 AM

Simplify Docker Management with Portainer CE on Linux: A Step-by-Step Guide Managing Docker containers via the command line can be daunting, especially for newcomers. Portainer CE (Community Edition) offers a free, lightweight, and intuitive solutio

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor