Ubuntu Server does not include a graphical user interface (GUI) by default. Some administration tools are easier to use with a GUI, and a desktop makes those tasks faster. This post shows how to install a display manager and a desktop environment on Ubuntu Server.
Prerequisites
- A system with Ubuntu Server installed
- An account with sudo or root privileges
- The APT package manager
Update the package index and packages
Before the installation, update the package index and upgrade the installed packages.
# sudo apt update
# sudo apt upgrade -y
Install and configure a display manager
A display manager starts the display server, starts the desktop session, and handles user authentication. The default, GDM3, uses a lot of resources. To save resources, use a lighter display manager such as SLiM or LightDM.
Install SLiM
Install the slim package.
# sudo apt install slim

Check /etc/X11/default-display-manager to make sure that SLiM is the default display manager.

Install LightDM
Install the lightdm package.
# sudo apt install lightdm
During the installation, debconf asks which display manager to use as the default. Select lightdm.

After the installation, make sure that the default display manager is now LightDM.

Install a desktop environment
Ubuntu Desktop
Install Ubuntu Desktop for the standard GNOME desktop.
# sudo apt install ubuntu-desktop
Reboot when the installation completes.
# sudo reboot
After the reboot, the LightDM login screen appears because LightDM is the default display manager.

KDE Plasma
KDE Plasma is a fast, flexible, and customizable desktop environment with a consistent visual style. Install it with this command.
# sudo apt install kde-plasma-desktop

Xfce
Xfce is lightweight and easy to use. The xfce4-session package gives a bare-bones environment. For a complete desktop, also install xfce4-goodies.
# sudo apt-get install xfce4-session xfce4-goodies

MATE
MATE is a fork of GNOME 2 with low resource usage. Install it with this command.
# sudo apt install ubuntu-mate-desktop

LXDE
LXDE is a very lightweight desktop. Use it to keep memory and CPU usage to a minimum.
sudo apt install lxde

Remove the GUI and the display manager
To remove the display manager and the desktop environment and go back to the command-line interface, do these steps.
Step 1. Remove the display manager and the desktop environment.
# sudo apt remove [display-manager] [desktop-environment]
For example, this command removes SLiM and LXDE.
# sudo apt remove slim lxde
Step 2. Reboot the system and log in again.
Step 3. Remove the dependencies that are no longer necessary.
# sudo apt autoremove
This is a referral link. I may receive credit if you sign up, at no extra cost to you.
Try it on a cloud server — Deploy Ubuntu on Vultr