1. Install the desktop environment
Ubuntu servers are usually managed using the command line and don't have a desktop environment installed by default. Skip this step if you are running Ubuntu desktop.
There are many desktop environments for you to choose from in the Ubuntu source repositories. One option is to install Gnome, which is the default desktop environment for Ubuntu 20.04. Another option is to install xfce. It's fast, stable, and lightweight, making it an ideal desktop for remote servers.
Run any of the following commands to install the desktop environment of your choice:
Install Gnome
sudo apt update
sudo apt-get upgrade
sudo apt install ubuntu-desktop
When installing ubuntu-desktop, select the first option
2. Install Xrdp
Xrdp is included in the default Ubuntu software repositories. To install it, run:
sudo apt install xrdp
Once the installation is complete, the Xrdp service will start automatically. You can verify it by typing the following command:
sudo systemctl status xrdp
The output will look like this:
● xrdp.service - xrdp daemon
Loaded: loaded (/lib/systemd/system/xrdp.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2020-05-22 17:36:16 UTC; 4min 41s ago
...
3. Use FinalShell to log in to the remote desktop
- Ports
xdrp
where access is allowed :3389
sudo ufw allow 3389
- If there are multiple linux accounts, it is best to turn off the firewall directly:
sudo ufw disable
4. View the current desktop system of Ubuntu20.04
echo $DESKTOP_SESSION
5. Uninstall the desktop
1. Uninstall xfce
$sudo apt-get remove xfce4
Uninstall related software
$sudo apt-get remove xfce4*
Automatically uninstall unnecessary software
$sudo apt-get autoremove
system cleaning
$sudo apt-get clean
2. Uninstall xubuntu-desktop
uninstall xubuntu
$ sudo apt-get remove xubuntu*
You also need to uninstall unnecessary software
$sudo apt-get autoremove
Note: The applications attached to xubutnu will also be deleted, that is, the commonly used software under xfce or xubuntu will also be uninstalled.
3. Uninstall gnome
# 卸载gnome
sudo apt-get remove gnome -y
# 卸载 gnome-shell
sudo apt-get remove gnome-shell -y
# 彻底卸载删除gnome的相关配置文件
sudo apt-get purge gnome -y
# 卸载臃肿的服务组件
sudo apt-get remove snapd -y
# 卸载依赖组件
sudo apt-get autoremove -y
# 清理安装gnome时候留下的缓存程序软件包
sudo apt-get autoclean
sudo apt-get clean
# 重启系统
sudo reboot
sudo shutdown -r now
Six, ubuntu20.04 close the graphical interface
Close the GUI and log in with xshell.
sudo systemctl set-default multi-user.target
sudo reboot
Start the graphical user interface.
sudo systemctl set-default graphical.target
sudo reboot
Windows 10 uses Xrdp remote desktop to connect to Ubuntu host - Programmer Sought
Ubuntu Server 20.04 installation desktop (graphical interface) and remote desktop
Ubuntu remote desktop connection - based on xrdp_ubuntu can't connect to xrdp - Programmer Sought