Installing a Graphical User Interface (GUI) on a server requires to understand how a desktop environment works and therefore what programs you need to install.

Table of Contents

In this tutorial we are going to install a GUI on Ubuntu Server 20.04, but these steps may work on other distributions (using their respective package managers).

Install a display server

A display server is a program that coordinates input and output of its clients to and from the rest of the operating system, the hardware and each other (Wikipedia), so it’s a key component of any graphical user interface. Most popular display servers are Xorg and Wayland (Wayland aims to be the successor of Xorg).

We are going to install Xorg.

sudo apt install xserver-xorg

In Arch Linux, package name is xorg-server.

This process may take some time.

(Optional) Display drivers

Your system may need drivers for the GPU. AMD and NVIDIA have open-source and propietary drivers (newer NVIDIA GPUs don’t support open-source drivers). Some open-source drivers will be installed with Xorg, so you need to check if your GPU will work with the installed drivers.

Install a desktop environment

A desktop environment bundles several X clients, such as a window manager, file manager, terminal emulator, icons and other utilities. There are many desktop environments: XFCE, GNOME, KDE, LXDE,… We are going to install XFCE.

sudo apt install xfce4 xfce4-goodies

During installation, it may show you a prompt in which you need to select a display manager. You can select any but for this tutorial I selected “lightdm”.

(Optional) Display manager

Most desktop environments install a display manager by default. A display manager is responsible of automatically starting the graphical environment and managing user logins. Most popular display managers are lightdm (Light Display Manager) and gdm (GNOME Display Manager).

sudo apt install lightdm lightdm-gtk-greeter

Check if your server has at least one display manager after installing the desktop environment (search for lightdm, gdm, lxdm, sddm).

If you have installed a display manager manually, you may need to enable it:

sudo systemctl enable lightdm
# Then reboot

If you want to change your default display manager after installed, run sudo dpkg-reconfigure <your-preferred-display-manager> and select the display manager you want to use.

sudo dpkg-reconfigure gdm3

(Optional) Window manager

Desktop environments include a window manager (e.g.: Xfwm is the window manager for XFCE). It is a system software that controls the placement and appearance of windows within a windowing system in a GUI. If you want to simplify your environment you can install only a window manager and not a full desktop environment. More information can be found on this link.

Reboot

Reboot your server and you will see a graphical login interface. When password input shows up, look for a button near the login window and make sure your desktop environment is selected. LightDM window

More considerations

You may need to set keyboard layout for X11 (if you are not using US keymap).

localectl set-x11-keymap <keymap>

Logout and keyboard layout will change.