Installing a GUI on a server isn’t the default choice, but for debugging, demos, or single-user remote desktop scenarios, a lightweight desktop + XRDP is a common combo. This article gives reproducible install and rollback steps for Ubuntu 24.04 (Debian family), with the verification boundaries written out for every step.
Verified: install commands’ dependency resolution was checked on WSL2 Ubuntu 24.04 via apt-get install -s; the desktop environment itself was not fully installed (~900 dependency packages), and the XRDP service unit files come from the actual contents of downloaded .deb packages. XRDP connection testing was not run on this machine.
One-line conclusion
Before installing a GUI on a server, confirm you actually need it: production servers usually don’t have one [1]. When you do need it, use tasksel to install the XFCE task, lightdm as the display manager, and xrdp for a remote desktop reachable from Windows RDP clients — three steps, all uninstallable and rollback-able.
Scope and prerequisites
- System: Ubuntu 24.04 LTS (Noble) or Debian 12; commands use Ubuntu as the example. On Debian, replace
task-xfce-desktopwith the same name. - Permissions: root or sudo required; commands here run as root (add
sudoprefix yourself if needed). - Resources: the XFCE task pulls ~900 packages, hundreds of MB of downloads, and several GB of disk after install; on low-memory machines see the resource notes in [1].
- Network: default repositories must be reachable; configure a proxy or mirror first on corporate networks.
Decide first: should the server have a GUI at all?
The Ubuntu community docs [1] consensus: don’t install a GUI on production servers — larger attack surface, more updates and downtime, and desktop processes consuming resources. Common alternatives:
- SSH + tmux / screen: terminal multiplexing, enough for most ops work.
- Web admin panels (Cockpit, Webmin, etc.): daily operations in the browser.
- Remote desktop only for temporary debugging: uninstall when done, avoid long-term exposure.
If you’ve confirmed you need a GUI, continue below; otherwise stop here.
Step 1: Install tasksel and the XFCE task
tasksel is the Debian family’s task installer that bundles related packages into a “task” [2]. Install tasksel first, then the xfce task:
apt-get update
apt-get install -y tasksel
tasksel install xfce-desktop
tasksel --list-tasks
tasksel --task-packages xfce-desktop
tasksel install xfce-desktop pulls in the task-xfce-desktop metapackage and its dependencies (XFCE 4.18 desktop, Thunar, xfce4-panel, etc.) [2]. You can also run apt-get install -y task-xfce-desktop directly with the same result; tasksel just handles debconf prompts.
Step 2: Install and enable lightdm display manager
The display manager handles the login screen and session startup. The XFCE task may already pull one in; install lightdm explicitly for control:
apt-get install -y lightdm
systemctl enable --now lightdm
systemctl is-active lightdm
systemctl is-enabled lightdm
During install, debconf asks for the default display manager — pick lightdm.
Expected output: active / enabled.
Step 3: Install XRDP and enable remote desktop
XRDP is an open-source RDP server; Windows’ built-in “Remote Desktop Connection” (mstsc) connects directly [3]. Install and enable both services:
apt-get install -y xrdp
systemctl enable --now xrdp xrdp-sesman
xrdp.service depends on xrdp-sesman.service (the session manager) [3]; once both are enabled they listen on TCP port 3389 [4]. Actual service unit contents (from Ubuntu 24.04’s xrdp 0.9.24-4ubuntu0.1 package):
xrdp.service:Type=forking,PIDFile=/run/xrdp/xrdp.pid,Requires=xrdp-sesman.service,After=network.target xrdp-sesman.service,WantedBy=multi-user.target.xrdp-sesman.service:Type=forking,BindsTo=xrdp.service,StopWhenUnneeded=true.
The default listen port is port=3389 in /etc/xrdp/xrdp.ini (uncommented line); change it if needed.
Step 4: Firewall and user session configuration
Allow port 3389 (when ufw is enabled):
ufw allow 3389/tcp
ufw status
echo "xfce4-session" > ~/.xsession
XRDP needs to know which desktop to start; the command above writes the session file for the current user.
XRDP uses /etc/xrdp/startwm.sh by default, which finally runs /etc/X11/Xsession, which reads ~/.xsession [3]. Every user needs their own ~/.xsession in multi-user setups.
Connect from Windows: run mstsc, enter the server IP, log in with a Linux username and password. Accept the certificate prompt on first connection.
Rollback and uninstall
Uninstall in reverse dependency order, then clean up config and data directories:
systemctl stop xrdp xrdp-sesman lightdm
apt-get purge -y "xrdp*" "lightdm*"
apt-get autoremove --purge -y
rm -rf /etc/xrdp /etc/lightdm /var/lib/xrdp
dpkg -l | grep -E 'xrdp|lightdm' || echo "uninstalled"
systemctl is-enabled xrdp 2>&1 || true
To also remove task-xfce-desktop and XFCE components, add apt-get purge -y "xfce4*" "task-xfce-desktop" and run autoremove --purge again. Client libraries that other software depends on may remain — that’s normal.
Troubleshooting quick reference
| Symptom | Cause | Fix |
|---|---|---|
| Black screen or instant disconnect after connect | ~/.xsession missing or wrong |
Rewrite echo xfce4-session > ~/.xsession and restart xrdp |
| mstsc shows “internal error” | xrdp-sesman not running | systemctl status xrdp-sesman, restart xrdp if needed |
| Connects but only grey screen | Display manager conflict (GDM and lightdm coexist) | dpkg-reconfigure lightdm, pick lightdm, restart |
| Port 3389 unreachable | Firewall or cloud security group not open | ufw allow 3389/tcp, and check the cloud console security group |
| Garbled locale after login | Chinese locale not generated | locale-gen zh_CN.UTF-8 and restart the session |
| XFCE panel crashes | Incompatible plugin | xfce4-panel -r to restart the panel |
Limitations
- Desktop environment not fully installed on this machine: dependency resolution verified via
apt-get install -s(task-xfce-desktop: ~899 new packages + 19 upgrades; xrdp + lightdm: ~546 new packages + 16 upgrades), but install and XRDP connection testing were not actually run. - XRDP connections, session startup, and multi-user concurrency were not tested; based on official docs and the package’s service unit files.
- Cloud servers need the security group to allow port 3389; this article only covers local ufw.
- Automatic graphical login after reboot was not verified on this machine; once
lightdmis enabled it starts a graphical login by default. On servers, confirmsystemctl get-default— switch back tomulti-user.targetif needed. - Task names and package versions differ between Debian and Ubuntu; commands target Ubuntu 24.04.
FAQ
Q1: Does a server really need a GUI? A: Most scenarios don’t. SSH and web admin panels cover daily ops; GUIs are mainly for desktop apps, graphical debugging, or demo environments.
Q2: XFCE vs other desktops (GNOME/KDE)? A: XFCE has the lowest resource footprint, good for servers and remote desktops; GNOME is more capable but heavier; KDE sits between. tasksel offers gnome-desktop, kde-desktop, lxqt-desktop tasks you can swap in.
Q3: Can XRDP coexist with GNOME Wayland? A: XRDP is Xorg-based, so pure Wayland sessions aren’t supported; GNOME needs to switch back to Xorg or use xrdp’s Xorg backend. Choosing XFCE avoids this.
Q4: How do I restrict remote desktop to specific users? A: XRDP allows all loggable users by default; control via PAM or session limits in /etc/xrdp/sesman.ini — see the man page.
Q5: What’s left after uninstall? A: apt-get autoremove --purge removes config, but ~/.xsession and ~/.config/xfce4 in user home directories need manual deletion.
Appendix A: Test record
- Test machine: WSL2 Ubuntu 24.04.4 LTS (Noble), systemd 255.
- Package versions: tasksel 3.75ubuntu1, task-xfce-desktop 3.75ubuntu1, xfce4 4.18, lightdm 1.30.0-0ubuntu14, xrdp 0.9.24-4ubuntu0.1.
- Verification commands:
apt-get update→ rc 0.apt-get install -s task-xfce-desktop→ dependency resolution succeeded, 19 upgraded / 899 newly installed / 0 removed / 160 not upgraded.apt-get install -s xrdp lightdm→ dependency resolution succeeded, 16 upgraded / 546 newly installed / 0 removed / 163 not upgraded.tasksel --list-tasksand--task-packages xfce-desktop→ outputtask-xfce-desktop.dpkg-deb -c xrdp_0.9.24...deb→ confirmed service unit file paths and contents.- Not run: full install,
systemctl enable --nowactually taking effect, XRDP connection test, rollback execution. - Cleanup: no packages installed, only downloaded tasksel / tasksel-data / xrdp .deb files to /tmp (WSL side), no persistent changes;
/usr/share/taskselwas extracted by tasksel-data as test residue, removable on next WSL restart or apt cleanup, doesn’t affect the host.
Appendix B: References
- [1] Ubuntu community docs “ServerGUI”: impact of GUI on servers and install advice.
- [2] tasksel(8) man page (Debian bookworm): task installer usage.
- [3] xrdp(8) man page (Debian bookworm): RDP server usage and port.
- [4] xrdp-sesman(8) man page (Debian bookworm): session manager usage.
Untested note: install and connection steps are based on official docs and package metadata; verify on a test machine before running.
References
- [1] ServerGUI – Community Help Wiki (servergui)
- [2] tasksel(8) — tasksel — Debian bookworm (tasksel-man)
- [3] xrdp(8) — xrdp — Debian bookworm (xrdp-man)
- [4] xrdp-sesman(8) — xrdp — Debian bookworm (xrdp-sesman-man)
Main commands tested on WSL Ubuntu (24.04); a few entries (uninstalled tools / install commands) were only checked against official docs, not actually run.