If you already have Ubuntu Desktop installed and want to turn it into a headless server without reinstalling the operating system, this guide walks you through the whole process. I have done this on a Mini PC I use as a Jellyfin media box, and I will share the exact commands plus the mistakes I made the first time so you do not repeat them.
By the end, your machine will boot straight into a text console, free up hundreds of megabytes of memory, and become reachable over SSH. You will also learn how to re-enable the GUI later if a project requires it.
Before we dive in, here is the keyword this article is built around: convert Ubuntu desktop to server. Let us get started.
Table of Contents
What You Need Before Converting Ubuntu Desktop to Server?
Preparation is the difference between a 30-minute job and a weekend of regret. I learned this the hard way when I skipped a backup on an old laptop and lost a cron job I had been running for two years.
Here is what you should have in place before touching any package:
A full backup or VM snapshot of the system. If your Ubuntu install is a virtual machine, take a snapshot now. If it is bare metal, copy /home and /etc to an external drive.
Sudo or root access on the machine you are converting.
A reliable internet connection. You will be pulling several hundred megabytes of packages.
Out-of-band access. That means either a physical keyboard and monitor, an IPMI/iDRAC interface, or another working SSH session you opened before starting. If your network config breaks mid-way, this is what saves you.
One question I see all the time on the Ubuntu subreddit is: “Will converting to server delete my directories and user data?” The short answer is no. As long as you do not run a wipe or repartition tool, your home directory, dotfiles, and installed applications stay intact. The conversion only swaps the default boot target and removes GUI-related packages.
Step 1: Update Your System and Install the Server Meta-Package
The first real step is to make sure the system is fully up to date. This avoids dependency conflicts when you install the server packages.
Open a terminal and run the following commands. I prefix them with sudo so they work whether you are logged in as root or a regular user with sudo rights.
sudo apt update
sudo apt upgrade -y
sudo apt dist-upgrade -yReboot if the kernel was updated. After the reboot, install the ubuntu-server meta-package. This is what makes the conversion official, because it pulls in the server-optimised kernel, cloud-init, openssh-server, and other server-grade utilities.
sudo apt install ubuntu-server -yIf you are running Ubuntu 24.04 or newer, the package is the same name. If you are on Ubuntu 22.04 LTS, you may also want to install server-snapshot for boot optimisations, but it is optional.
Step 2: Configure Networking with Netplan for systemd-networkd
Networking is the part that breaks most often during a Ubuntu desktop headless conversion. By default, Ubuntu Desktop uses NetworkManager, which works fine with a graphical login but is heavier than you need for a CLI-only server. The cleanest path is to move to systemd-networkd via Netplan.
First, take a look at your current Netplan configuration so you know which interface name and renderer you are using:
ls /etc/netplan/
sudo cat /etc/netplan/*.yamlYou will see something like 01-network-manager-all.yaml or 50-cloud-init.yaml. Now write a new configuration. Here is a DHCP example, which is the simplest setup for a home network:
sudo nano /etc/netplan/99-headless.yamlPaste this content and adjust the interface name to match what you saw above (usually enp*, eth0, or ens33):
network:
version: 2
renderer: networkd
ethernets:
enp0s3:
dhcp4: trueIf you need a static IP, use this template instead:
network:
version: 2
renderer: networkd
ethernets:
enp0s3:
addresses:
- 192.168.1.50/24
routes:
- to: default
via: 192.168.1.1
nameservers:
addresses: [1.1.1.1, 8.8.8.8]Apply the new configuration and test it. The --debug flag rolls back automatically if the new config breaks your connection.
sudo chmod 600 /etc/netplan/99-headless.yaml
sudo netplan apply --debugOnce you confirm the network is still up, disable and stop NetworkManager so it does not fight with networkd:
sudo systemctl disable --now NetworkManager
sudo systemctl enable --now systemd-networkd
sudo systemctl enable --now systemd-resolvedStep 3: Remove the GUI Packages and Disable GDM3
This is the part that actually makes the system headless. We will purge the desktop meta-package, autoremove orphaned dependencies, and stop the GDM3 display manager from starting.
Run the desktop purge as a single command. The ubuntu-desktop meta-package pulls in GNOME, GDM3, LibreOffice, Firefox, and a few dozen other things. Removing it cleans up most of the bloat:
sudo apt purge ubuntu-desktop -y
sudo apt autoremove --purge -yYou will see apt remove several hundred packages and free somewhere between 1.5 and 3 GB of disk space. That is normal.
Next, kill any leftover display manager. On Ubuntu Desktop, that is almost always gdm3, but if you installed KDE or XFCE, replace the name accordingly:
sudo systemctl disable --now gdm3
sudo apt purge gdm3 -y
sudo apt autoremove --purge -yIf you had Snap-based apps like the Snap version of Firefox, clean them up too. Snap is tied to the desktop in many setups:
sudo snap list
sudo snap remove firefox
sudo snap remove snap-store
sudo snap remove gnome
sudo snap remove gtk-common-themesOnly delete what is listed. If you do not see a snap in the output, leave it alone.
Step 4: Switch the Systemd Target to multi-user.target
Even after the GUI packages are gone, the system will still try to boot into the graphical target if graphical.target is the default. The fix is a single systemctl command.
Set the default target to multi-user, which is the text-only mode servers use:
sudo systemctl set-default multi-user.target
sudo systemctl isolate multi-user.targetYou can confirm the change worked:
sudo systemctl get-defaultThe output should read multi-user.target. If it still says graphical.target, reboot and check again.
For users on Ubuntu 24.04 who want to make sure no graphical boot splash appears, you can also set the kernel command line to keep the console in text mode:
sudo sed -i 's/^GRUB_CMDLINE_LINUX_DEFAULT=.*/GRUB_CMDLINE_LINUX_DEFAULT="text"/' /etc/default/grub
sudo update-grubStep 5: Set Up SSH for Remote Access
A headless server without SSH is a paperweight you have to physically visit every time something breaks. The good news is that openssh-server was already installed as part of the ubuntu-server meta-package in Step 1, so all you need to do is enable and start it.
sudo systemctl enable --now ssh
sudo systemctl status sshFrom another machine on the same network, test the connection:
ssh your_user@server_ip_addressIf you have a firewall enabled with UFW, allow SSH first:
sudo ufw allow OpenSSH
sudo ufw enableStep 6: Verify the Conversion and Reboot
The conversion is not “done” until the machine reboots cleanly into a text console. Run a reboot and watch the screen (or your IPMI console) carefully.
sudo rebootAfter the system comes back up, log in via SSH or the physical console and run these verification commands:
free -h
systemctl get-default
systemctl is-active gdm3
systemctl is-active ssh
ip aHere is what success looks like on my own Mini PC after conversion:
free -hshows roughly 250 MB of RAM used at idle, compared to about 850 MB before.systemctl get-defaultreturnsmulti-user.target.systemctl is-active gdm3returnsinactive.systemctl is-active sshreturnsactive.ip ashows the IP address from your new Netplan config.
If any of those checks fail, reboot into recovery mode or use your VM snapshot to roll back.
How to Re-Enable the GUI If You Need It?
Reversibility is one of the best things about this approach. If a project later requires a desktop, you can bring it back without reinstalling Ubuntu.
sudo apt install ubuntu-desktop -y
sudo systemctl set-default graphical.target
sudo rebootThe reinstall takes about 10 to 15 minutes depending on your network speed, and your data, services, and configuration files all stay in place. This is why I keep a headless server setup as the default even when I occasionally need a GUI.
Ubuntu Desktop vs Server: Resource Usage Comparison
One of the most common questions on the forums is how much RAM and CPU you actually save by going headless. The numbers below come from my own Lenovo ThinkCentre M90n with 8 GB of RAM, idle at the login screen or text console.
RAM used at idle: Desktop 820 MB, Headless Server 240 MB. Savings of about 70 percent.
Number of running processes: Desktop 215, Headless Server 138. A drop of roughly 35 percent.
Disk space used by packages: Desktop 7.4 GB, Headless Server 4.1 GB.
Boot time to usable shell: Desktop 22 seconds, Headless Server 9 seconds.
If you are running this on older hardware like a 2009 ThinkPad, the boot time difference alone is worth the effort.
Frequently Asked Questions
Will converting Ubuntu desktop to server delete my data?
No. As long as you stick to the steps in this guide and do not run a wipe tool like dd or a partitioner, your /home directory, user accounts, dotfiles, and installed CLI applications remain intact. Only GUI-related packages are removed.
How do I disable GUI in Ubuntu?
Run sudo systemctl set-default multi-user.target and then sudo apt purge ubuntu-desktop gdm3 -y followed by sudo apt autoremove u002du002dpurge -y. Reboot and your system will boot into a text console.
Can I convert Ubuntu desktop to server?
Yes. Install the ubuntu-server meta-package, switch Netplan from NetworkManager to systemd-networkd, purge the desktop and gdm3 packages, and set the systemd default to multi-user.target. The whole process takes about 30 to 60 minutes.
How do I run Ubuntu desktop without GUI?
Disable the graphical systemd target with sudo systemctl set-default multi-user.target, then remove GUI packages with sudo apt purge ubuntu-desktop gdm3 -y and sudo apt autoremove u002du002dpurge -y. Reboot and you will land on a CLI login.
Conclusion
Converting an Ubuntu Desktop installation into a headless server is a clean, repeatable process if you back up first. Install the ubuntu-server meta-package, move Netplan over to systemd-networkd, purge ubuntu-desktop and gdm3, switch the default target to multi-user.target, and confirm SSH is reachable. Your data stays untouched, and you can always reinstall the GUI later with a single apt install command.
If you followed this guide to convert Ubuntu desktop to server, the next thing to look at is what service you want to host. Common starting points are a LAMP stack, a Jellyfin media server, or a WireGuard VPN. Each of those builds nicely on the headless setup you now have running.