1. Overview

Graphical User Interface (GUI) packages enable users to interact with the operating system using the graphical interface. They offer alternative means of interaction with the system instead of solely relying on a Command Line Interface (CLI).

These packages contain software components that customize graphical desktop environments, window managers, display managers, and other related tools.

Removing all GUI packages from a Debian-based system reverts the operating system to a CLI environment. However, executing this process requires utmost attention and a systematic approach that involves creating a backup of the system.

In this tutorial, we’ll learn how to safely achieve this process.

2. Removing GUI Packages in Debian

On Debian, we remove all the GUI packages by removing the libraries that connect these packages to the display.

These two libraries, libx11-6 and libwayland-client0, offer core client-side functionality for graphical applications to display content and receive user input in both Unix-like systems and modern display server environments.

By removing these two libraries and their relative dependencies and packages, we invariably revert our operating system to a CLI-based one.

Before proceeding, it’s a good practice to create a backup of the system. Subsequently, this ensures that we can restore any missing dependencies or packages if we mistakenly uninstall them and later need them.

2.1. Simulating Removal of Packages

Now, let’s simulate the removal of these libraries and all their dependencies using the sudo apt-get purge command. This will give us the list and number of packages that the process intends to uninstall:

$ sudo apt-get --dry-run purge libx11-6 libwayland-client0
Reading package lists...
Building dependency tree...
Reading state information...
The following packages were automatically installed and are no longer required:
  accountsservice acl adwaita-icon-theme aspell aspell-en
  aspnetcore-runtime-6.0 aspnetcore-targeting-pack-6.0 at-spi2-common
  atril-common base58 bluez-obexd bubblewrap colord-data cracklib-runtime
  cython3 dcraw debtags debugedit dictionaries-common dnsmap dnsmasq-base
  docbook-xml dotnet-apphost-pack-6.0 dotnet-host dotnet-hostfxr-6.0
  dotnet-runtime-6.0 dotnet-runtime-deps-6.0 dotnet-sdk-6.0
  dotnet-targeting-pack-6.0 emacsen-common enchant-2 engrampa-common
  xfce4-screenshooter* xfce4-sensors-plugin* xfce4-session* xfce4-settings* xfce4-systemload-plugin* xfce4-taskmanager* xfce4-timer-plugin*
  xfce4-verve-plugin* xfce4-wavelan-plugin* xfce4-whiskermenu-plugin* xfce4-xkb-plugin* xfdesktop4* xfwm4* xiccd* xinit* xkbset* xorg* xrdp*
  xserver-common* xserver-xephyr* xserver-xorg* xserver-xorg-core* xserver-xorg-input-all* xserver-xorg-input-libinput* xserver-xorg-legacy*
  xserver-xorg-video-all* xserver-xorg-video-amdgpu* xserver-xorg-video-ati* xserver-xorg-video-fbdev* xserver-xorg-video-nouveau*
  xserver-xorg-video-radeon* xserver-xorg-video-vesa* xserver-xorg-video-vmware* xterm* xtightvncviewer* xvfb* yelp* zenity*
0 upgraded, 0 newly installed, 491 to remove and 0 not upgraded.
Purg wifite [2.7.0-1]
Purg fern-wifi-cracker [3.4-0kali1]
Purg aircrack-ng [1:1.7-5] [bully:amd64 ]
Purg orca [46.0-1] [bully:amd64 ]
Purg python3-pyatspi [2.46.1-1] [bully:amd64 ]

The ‐‐dry-run option tells sudo apt-get purge to simulate the real uninstallation process. Therefore, the system lets us preview the packages that would be removed during the actual execution of the process. However, due to space constraints, the above result only displays a few of the listed packages

More so, the sixth line from the bottom of the output above shows that the system intends to remove 491 packages for the client-side libraries.

2.2. Removing the GUI Packages

Let’s proceed with the removal process and observe how our system reverts to CLI:

$ sudo apt-get purge libx11-6 libwayland-client0

The result from the command above is the same as the previous ‐‐dry-run output, the only difference being that the packages were actually uninstalled this time.

Let’s proceed to use the apt-get autoremove command to remove all the packages that had been automatically installed as dependencies but are no longer required:

$ sudo apt-get autoremove
Reading package lists...
Building dependency tree...
Reading state information...
The following packages will be REMOVED:
  accountsservice acl adwaita-icon-theme aspell aspell-en
  aspnetcore-runtime-6.0 aspnetcore-targeting-pack-6.0 at-spi2-common
  atril-common base58 bluez-obexd bubblewrap colord-data cracklib-runtime
  wpasupplicant x11proto-dev xbitmaps xdg-dbus-proxy xdg-desktop-portal xfce4-helpers xfce4-power-manager-data xfoconf xfdesktop4-data
  xl2tpd xorg-docs-core xorg-sgml-doctools xsltproc xtrans-dev yelp-xsl zenity-common zerofree
0 upgraded, 0 newly installed, 957 to remove and 0 not upgraded.
After this operation, 2,570 MB disk space will be freed.
Do you want to continue? [Y/n]
(Reading database ... 395004 files and directories currently installed.)
Removing accountsservice (23.13.9-6) ...
Removing acl (2.3.2-1) ...
Removing adwaita-icon-theme (46.0-1) ...
Removing enchant-2 (2.3.3-2+b1) ...

The command apt-get autoremove uninstalled all the leftover packages and dependencies by actively cleaning up after the apt-get purge command we initiated earlier. In addition, the clean-up reported the number of removed packages as its result.

3. Log in to the CLI Environment

Next, we’ll execute the reboot command to restart the system from the CLI, which shows that we’ve finally reverted our operating system to a CLI-based environment.

Let’s reboot from the CLI:

$ reboot

After that, the system reboots to a CLI login terminal, which becomes our default login environment since we’ve deleted our GUI:

Kali GNU/Linux Rolling kali tty1
kali login: kali
Linux kali 6.6.9-amd64 #1 SMP PREEMPT_DYNAMIC Kali 6.6.9-1kali1 (2024-01-08) x86_64
The programs included with the Kali GNU/Linux system are free software;
the exact distribution terms for each programme are described in the
individual files in /usr/share/doc/*/copyright.

Kali GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last Login: Mon Apr 1 16:01:03 EDT 2024 on tty1
   (Message from Kali developers)
  This is a minimal installation of Kali Linux, you likely
  want to install supplementary tools. Learn how:

  (Run: touch ~/.hushlogin to hide this message)
$ whoami

The output above displays the login terminal, where we enter the login username and password to begin interacting with our CLI environment.

The CLI welcomes us with a message that details the type of Linux distribution we’re using and the warranty.

We then interact with the interface by entering the whoami command to print the username of the current user. Now, we have only the CLI environment on the operating system to perform our administrative duties.

4. Conclusion

This article provides a comprehensive guide for safely removing GUI packages from a Debian-based system. Furthermore, the backup created enables us to restore any needed dependencies and packages for the CLI interface.

Invariably, users may choose to remove all GUI packages from their Debian-based system for reasons such as aiming for a lightweight operating system or preferring a CLI-only environment.

Comments are open for 30 days after publishing a post. For any issues past this date, use the Contact form on the site.