Currently Available: Need a skilled Software Developer for your next project?
Categories
Linux Servers

How to Turn an Ubuntu Desktop Install Into a Headless Server Without Reinstalling

If Ubuntu Desktop is already installed on a computer you want to run without a monitor, you can keep that installation and make it start without the graphical login. “Headless” means you operate the computer remotely or without a screen and keyboard attached. Ubuntu uses systemd, the software that manages startup, to choose whether it starts with a graphical login or in a non-graphical, multi-user mode.

The safest path is to set up and test remote access first, then change the default boot target. Keep the desktop packages installed initially: removing them is unnecessary for headless operation and makes recovery harder.

Prepare the computer and update Ubuntu

Before changing boot behavior, back up important data. Note the Ubuntu release and current IP address. Also note the network connection and services the computer must keep running. Keep local access available for the first reboot. If SSH or networking fails, a keyboard and screen let you troubleshoot without relying on a remote connection.

A wired network connection is straightforward for a stationary server. If the computer gets its network address automatically through DHCP, ask the router to reserve an address for it so you can find it at the same address. Update the installed packages before configuring remote access:

sudo apt update
sudo apt upgrade

Ubuntu’s security guidance recommends keeping software up to date. Check that the computer will remain powered on, too. A laptop may suspend when its lid closes; Ubuntu’s lid-close guidance explains how to change that behavior and warns that running a closed laptop in a confined space can create an overheating risk.

Set up and test SSH

SSH, or Secure Shell, provides an encrypted connection for remote command-line access. Install Ubuntu’s OpenSSH server package and start the service:

sudo apt install openssh-server
sudo systemctl enable --now ssh

Check that the SSH service is running and find the computer’s IP address:

systemctl status ssh
hostname -I

From another computer on the same network, test a login using your Ubuntu username and the server’s address:

ssh username@server-ip

Create a key pair on the client computer, then copy its public key to the Ubuntu machine to authenticate without entering the account password each time:

ssh-keygen -t ed25519
ssh-copy-id username@server-ip

Ubuntu’s OpenSSH documentation covers key-based access and SSH configuration. Confirm that a remote login works before changing firewall rules, disabling password authentication, or turning off the graphical boot.

Check firewall access before enabling it

Ubuntu’s Uncomplicated Firewall, or UFW, is a tool for allowing or blocking network traffic. Check whether another firewall tool or network policy already manages traffic before changing UFW settings. If you intend to use UFW, allow SSH before enabling the firewall, then review the rules:

sudo ufw allow OpenSSH
sudo ufw status
sudo ufw enable

Only enable UFW if it fits the computer’s existing firewall setup. If you expose another service, such as file sharing or a web server, allow the required traffic as well. Ubuntu’s firewall documentation describes UFW and its default disabled state.

Boot without the graphical login

A systemd target is a named boot state that starts a set of services. Ubuntu uses graphical.target for a graphical login; multi-user.target starts a non-graphical, multi-user system. Set the non-graphical target as the default:

systemctl get-default
sudo systemctl set-default multi-user.target

Changing the default does not close the desktop session you are currently using. Reboot after confirming SSH access:

sudo reboot

Then connect again over SSH. Ubuntu’s systemd documentation describes the relationship between the graphical and multi-user targets. To restore the graphical login as the default later, run:

sudo systemctl set-default graphical.target

Keep the existing network configuration

A headless computer still needs a working network connection. Ubuntu Desktop installations commonly use NetworkManager, a service that manages network connections. Ubuntu’s Server networking examples often use networkd, a different network management service. Do not copy a Server Netplan example or switch network managers just because the computer now boots without a graphical login. Ubuntu explains the distinction in its network configuration documentation.

Make only the network changes you need. After rebooting, a successful SSH login confirms that another computer can reach the server over the network. That is a more useful test than seeing a network interface listed locally.

Leave desktop packages installed unless you have a reason to remove them

Changing the boot target avoids starting the graphical login by default. Keeping the desktop packages preserves the option to restore local graphical access and avoids package-removal risks.

If you need to reclaim disk space, treat package cleanup as a separate task. Package dependencies vary by Ubuntu release and flavor; the Ubuntu 24.04 package listing, for example, describes that release’s ubuntu-desktop metapackage. A metapackage helps install a group of packages, and removing it does not by itself define a safe, universal way to remove every desktop component. Review APT’s proposed changes before approving them. Preserve packages needed for networking and drivers. Also keep packages for firmware and SSH, along with packages your services need. Ubuntu’s package-removal guidance warns that removing packages can cause unexpected loss of functionality.

The change avoids starting the graphical login at boot, but it does not guarantee a particular reduction in memory use, CPU use, boot time, or power consumption. Those results depend on the hardware, installed packages, and running services.

What I'm building

Delegate tasks. Get software.

Give Vroni a GitHub issue, bug report, spec, or rough idea. It reads the repo, plans the change, writes code, runs checks, and works toward a review-ready pull request.

Take a look at vroni.com

Email updates

Usually a new article and a few links I found interesting.

No spam. Unsubscribe with one click.

Leave a Reply

Your email address will not be published. Required fields are marked *