# Graphical Desktops

> GNOME, KDE Plasma and Xfce at a glance, and the protocols that put a desktop on another screen: XDMCP, VNC, Spice and RDP.

Source: https://aminbytes.dev/bytes/user-interfaces-and-desktops/graphical-desktops/


Windows has one desktop and macOS has one desktop. Linux has many. The same Debian install can look like a polished tablet interface, a classic start menu, or a lean panel that runs happily on a ten-year-old laptop. They all sit on the same base: a display server (X11 or Wayland), a window manager and a set of apps. The bundle is called a **desktop environment**.

The exam only asks for *awareness* here: know the big three by name and toolkit, and know which protocol to use when the desktop is on another machine.

## The major desktop environments

| | GNOME | KDE Plasma | Xfce |
| --- | --- | --- | --- |
| Toolkit | GTK | Qt | GTK |
| Window manager | Mutter (also the compositor) | KWin | Xfwm4 |
| Usual display manager | GDM | SDDM | LightDM |
| File manager | Files (Nautilus) | Dolphin | Thunar |
| Terminal | Console or GNOME Terminal | Konsole | xfce4-terminal |
| Feel | Simple, modern, few settings | Very configurable, Windows-like by default | Light, classic, low on memory |
| Default on | Fedora Workstation, RHEL, Ubuntu, Debian | Kubuntu, Fedora KDE, openSUSE (one of the choices) | Xubuntu, many light distros |

- **GNOME** is the most common default on big distributions. It uses an "Activities" overview instead of a classic taskbar. Ubuntu ships it with a dock and some tweaks.
- **KDE** is the name of the community. Its desktop is **Plasma**, and it also makes many apps (Kdenlive, Krita, Okular). Almost everything can be changed in System Settings.
- **Xfce** is the light one. It's a good pick for older hardware, virtual machines and remote desktops, where every bit of speed counts.

Some others you will meet: **Cinnamon** (Linux Mint), **MATE** (a fork of the old GNOME 2), **LXQt**, and **Budgie**. Some people skip a full desktop and run only a window manager like i3, Openbox, or Sway on Wayland.

Toolkits don't lock you in: GTK apps run fine on KDE, and Qt apps run fine on GNOME. They just may look a little different from their neighbors.

 (Side note: You can install several desktops side by side. The display manager shows a session menu (often a gear icon) on the login screen where you pick one before logging in.)

### Which one am I running?

```bash
echo $XDG_CURRENT_DESKTOP
echo $XDG_SESSION_TYPE
```

```console
GNOME
wayland
```

### Installing a desktop

```bash
# Debian: "tasks" pull in a full desktop
sudo apt install task-xfce-desktop       # or task-gnome-desktop, task-kde-desktop

# Ubuntu: flavor meta-packages
sudo apt install xubuntu-desktop         # or kubuntu-desktop

# Fedora: package groups
sudo dnf install @xfce-desktop-environment

# RHEL: only GNOME is shipped ("Server with GUI"); KDE and Xfce come from EPEL
sudo dnf groupinstall "Server with GUI"
```

## X11 under every desktop

All of these desktops started on **X11**, the X Window System from the [previous byte](../x11/). X11 gives the basics: drawing, input and the network-transparent X protocol. The desktop adds everything you actually see. Today GNOME and KDE default to Wayland, and Xfce is moving there, but X11 is still the common ground, and X apps keep working through XWayland.

## Desktops on another machine

Sometimes the desktop you need isn't in front of you: a server in a rack, a virtual machine, or a colleague's Windows PC. Linux has several protocols for that, each with a different idea of *what* travels over the network.

| Protocol | What travels | Default port | Typical use |
| --- | --- | --- | --- |
| **X11 forwarding** (over SSH) | X drawing commands for single windows | 22 (SSH) | Run one graphical app from a server |
| **XDMCP** | A login screen, then X traffic | UDP 177 | Thin X terminals on a trusted LAN |
| **VNC** | Pixels of a whole desktop | TCP 5900 + display | Cross-platform remote desktop |
| **Spice** | Display, sound, USB and clipboard of a VM | Set per VM (often from 5900) | KVM / QEMU virtual machines |
| **RDP** | A whole desktop, compressed and encrypted | TCP 3389 | Windows servers; also Linux via xrdp or GNOME |

### XDMCP: X's own remote login

The **X Display Manager Control Protocol** lets an X server on one machine ask a display manager on another machine for a login screen. You log in, and the whole session runs on the remote host while being drawn on your local X server.

```bash
# from a text console: start a local X server that asks "server" for a login
X :1 -query server.example.com

# or inside your current desktop, in a nested window
Xephyr :1 -query server.example.com
```

`-query` asks one host directly, `-broadcast` asks the whole LAN, and `-indirect` shows a chooser list. The display manager must allow it: for example `Enable=true` in the `[xdmcp]` section of GDM's config, or `enabled=true` under `[XDMCPServer]` in `/etc/lightdm/lightdm.conf`.

> [!WARNING]
> XDMCP and the X traffic after it are **not encrypted**. Passwords and keystrokes cross the network in the clear. Use it only on a trusted network, or not at all.

### VNC: share the pixels

**VNC** (Virtual Network Computing) sends pictures of the screen one way and mouse and keyboard events the other way, using the RFB (Remote Framebuffer) protocol. It doesn't care what drew the screen, so it works between Linux, Windows and macOS. Display *n* listens on TCP port **5900 + n**.

There are two kinds of VNC servers:

- A **virtual desktop** server like TigerVNC's `vncserver` starts a new, invisible session just for the remote user.
- A **screen sharing** server like `x11vnc`, KDE's Krfb, or GNOME's Screen Sharing shows the desktop that's already on the physical monitor.

```bash
# on the server (Debian/Ubuntu: tigervnc-standalone-server, RHEL/Fedora: tigervnc-server)
vncpasswd          # set the VNC password
vncserver :1       # start virtual desktop :1, port 5901
vncserver -list
vncserver -kill :1
```

```console
TigerVNC server sessions:

X DISPLAY #	RFB PORT #	RFB UNIX PATH	PROCESS ID #	SERVER
1         	5901      	             	2318        	Xtigervnc
```

On RHEL and Fedora, run it as a systemd service instead: map the display to a user in `/etc/tigervnc/vncserver.users` (a line like `:1=amin`), then `sudo systemctl enable --now vncserver@:1`.

VNC itself is weakly protected. Classic VNC passwords use only 8 characters, and the stream is often unencrypted. The safe habit is to tunnel it through SSH:

```bash
ssh -L 5901:localhost:5901 amin@server     # forward local 5901 to the server
vncviewer localhost:1                      # in another terminal
```

### Spice: made for virtual machines

**Spice** (Simple Protocol for Independent Computing Environments) is the remote display protocol of QEMU/KVM virtual machines, usually managed with libvirt and `virt-manager`. Unlike VNC it carries more than pixels: sound, USB devices, clipboard and automatic screen resizing. Inside the guest, the `spice-vdagent` service makes clipboard and resizing work.

```bash
virt-viewer my-vm                     # open a libvirt VM's console by name
remote-viewer spice://kvm-host:5900   # or connect to a Spice address
```

Debian, Ubuntu and Fedora ship Spice. Red Hat deprecated it in RHEL 8 and dropped it from RHEL 9's KVM, where VNC is used instead.

### RDP: the Windows protocol

**RDP** (Remote Desktop Protocol) comes from Microsoft and is how you reach Windows desktops and servers. It's encrypted, compresses well over slow links, and listens on TCP port **3389**. Linux speaks it in both directions:

- **Client:** Remmina (a GUI that also does VNC, Spice and SSH) or FreeRDP on the command line.
- **Server:** `xrdp` gives a Linux machine an RDP login (from EPEL on RHEL), and GNOME's built-in Remote Desktop uses RDP since GNOME 42.

```bash
xfreerdp /v:winserver.example.com /u:amin
```

 (Side note: FreeRDP 3 renamed its client to `xfreerdp3` (and added `sdl-freerdp3`) on some distros. The `/v:` and `/u:` options stay the same.)

```bash
# Debian / Ubuntu: turn a Linux box into an RDP server
sudo apt install xrdp
sudo systemctl enable --now xrdp
```

## Exam checklist

- Know the big three: **GNOME** (GTK, Mutter, GDM), **KDE Plasma** (Qt, KWin, SDDM), **Xfce** (GTK, Xfwm4, light).
- A desktop environment = window manager + panels + file manager + settings + apps, on top of X11 or Wayland.
- **XDMCP**: remote X login, UDP 177, unencrypted. Clients use `X -query host` or `Xephyr -query host`.
- **VNC**: pixels of a whole desktop over RFB, port 5900 + display number; tunnel it through SSH.
- **Spice**: remote display for QEMU/KVM virtual machines, with sound, USB and clipboard.
- **RDP**: Microsoft's protocol, TCP 3389; `xrdp` is the Linux server, Remmina and `xfreerdp` are clients.
- For a single app, SSH X11 forwarding (`ssh -X`) is often all you need.


## Byte check

1. Which desktop environment is built on the **Qt** toolkit and uses the KWin window manager?
   - GNOME
   - **KDE Plasma** (correct)
   - Xfce
   KDE Plasma uses Qt and KWin. GNOME and Xfce both use GTK, with Mutter and Xfwm4 as their window managers.

2. A VNC server runs desktop `:2`. Which TCP port does a viewer connect to?
   - **`5902`** (correct)
   - `3389`
   - `6002`
   VNC uses port 5900 plus the display number. 3389 is RDP, and 6002 would be an X server on display 2.

3. Which protocol lets a remote **X server** ask a display manager for a login screen, over UDP port 177?
   - Spice
   - **XDMCP** (correct)
   - RDP
   XDMCP (X Display Manager Control Protocol) is X's own remote login protocol. It is unencrypted, so it's only for trusted networks.


