Disabling the GUI (and boot into GUI) on Ubuntu

This guide provides steps to disable the graphical user interface on an Ubuntu system, particularly useful when the system is primarily accessed via SSH.

Disabling the Display Manager Service

1. Identify Your Display Manager

Determine which display manager your system is using. Common ones are gdm3, lightdm, or sddm. Use the following command to check the status:

systemctl status gdm3
systemctl status lightdm
systemctl status sddm

2. Disable the Display Manager

Once you have identified your display manager, disable it using:

sudo systemctl disable gdm3

Replace gdm3 with lightdm or sddm as per your system.

Setting System to Boot into Multi-User Target

1. Check Current Target

First, check your current default target:

systemctl get-default

2. Switch to Multi-User Target

Set the system to boot into a command-line environment by default:

sudo systemctl set-default multi-user.target

Verifying the Changes

After making these changes, either reboot the system or check the status of the display manager service:

systemctl status gdm3

Replace gdm3 with your display manager's name.

Reverting Back to GUI

If you need to revert back to the GUI, re-enable the display manager service and/or set the default target back to graphical.target:

sudo systemctl enable gdm3
sudo systemctl set-default graphical.target

Replace gdm3 with your specific display manager.