I would like to uninstall and remove all the packages that are associated with Gnome GUI Desktop environment on my Rocky / AlmaLinux / CentOS 9|8 Linux system. Choosing an option of Server with GUI when installing Rocky Linux, CentOS Stream, or AlmaLinux 9/8 from DVD ISO or network boot, by default the “Xserver and GNOME desktop environments” are installed. When the GUI tools are removed you can only administer the system from CLI command-line mode – console or SSH.
Before removing Gnome and other GUI tools confirm that there are no applications installed on the system that require a graphical user interface to operate. Before you can proceed it’s good to confirm your system OS details by checking the contents of the /etc/os-release
file.
$ cat /etc/os-release
NAME="Rocky Linux"
VERSION="9.3 (Blue Onyx)"
ID="rocky"
ID_LIKE="rhel centos fedora"
VERSION_ID="9.3"
PLATFORM_ID="platform:el9"
PRETTY_NAME="Rocky Linux 9.3 (Blue Onyx)"
ANSI_COLOR="0;32"
LOGO="fedora-logo-icon"
CPE_NAME="cpe:/o:rocky:rocky:9::baseos"
HOME_URL="https://rockylinux.org/"
BUG_REPORT_URL="https://bugs.rockylinux.org/"
SUPPORT_END="2032-05-31"
ROCKY_SUPPORT_PRODUCT="Rocky-Linux-9"
ROCKY_SUPPORT_PRODUCT_VERSION="9.3"
REDHAT_SUPPORT_PRODUCT="Rocky Linux"
REDHAT_SUPPORT_PRODUCT_VERSION="9.3"
The OS we’re using in this article is Rocky Linux 9 Server with Desktop environment powered by Gnome.
Check Installed package groups
Installing packages from a group pulls a “group of dependent packages” that serve a common purpose. Each package group has a name and a groupid (GID).
Switch to root user.
su - root
To check available package groups – online and installed run the commands given below.
# dnf grouplist
Last metadata expiration check: 2:44:40 ago on Thu 25 Jan 2024 09:14:42 PM EAT.
Available Environment Groups:
Server
Minimal Install
Workstation
Custom Operating System
Virtualization Host
Installed Environment Groups:
Server with GUI
Installed Groups:
Container Management
Headless Management
Available Groups:
Legacy UNIX Compatibility
Console Internet Tools
Development Tools
.NET Development
Graphical Administration Tools
Network Servers
RPM Development Tools
Scientific Support
Security Tools
Smart Card Support
System Tools
You can also list the names of all package groups, and, next to each of them, their groupid in parentheses by running the commands below.
dnf group list -v
Option 1: Only remove X and Gnome packages
The safest method is where you only delete X server and Gnome packages. But first set default systemd target to multi-user.target. This means the OS will start a multiuser system with networking, and no graphical environment.
systemctl set-default multi-user.target
You can now proceed to remove ‘GNOME‘ and ‘X Window System‘ package groups.
dnf groupremove 'GNOME' 'X Window System'
If successful you should see “Complete!” message the end.
...
Complete!
If you had a separate “Graphical Administration Tools“, then remove it as well.
# dnf groupremove "Graphical Administration Tools" --nobest --skip-broken
Warning: Module or Group 'Graphical Administration Tools' is not installed.
Dependencies resolved.
Nothing to do.
Complete!
Ensure “Minimal Install” group packages are installed.
$ sudo dnf groupinstall -y "Minimal Install"
Dependencies resolved.
======================================================================================================================================================================================================
Package Architecture Version Repository Size
======================================================================================================================================================================================================
Installing Environment Groups:
Minimal Install
Installing Groups:
Core
Transaction Summary
======================================================================================================================================================================================================
Complete!
Reboot the system once done to enjoy your new terminal based OS operations.
shutdown -r now
Option 2: Remove everything with GUI
If you wanted to clean up all tools packaged in “Server with GUI” group, then run the commands below.
yum groupremove "Server with GUI" --skip-broken --nobest
This is not considered to be a safe method since it can result in some packages breaking yet needed for Minima Server operations.
Restoring Desktop GUI Environment
To get back your server with a fully functional desktop experience, install the group which provides an integrated, and easy-to-manage server with a graphical interface.
dnf groupinstall "Server with GUI"
This will install the following mandatory groups.
- Common NetworkManager submodules
- Container Management
- Core
- Fonts
- GNOME
- Guest Desktop Agents
- Hardware Monitoring Utilities
- Hardware Support
- Headless Management
- Internet Browser
- Multimedia
- Printing Client
- Server product core
- Standard
- base-x
Accept packages installation prompt to begin the process.
....
Installing Environment Groups:
Server with GUI
Installing Groups:
base-x
Container Management
Core
Fonts
GNOME
Guest Desktop Agents
Hardware Monitoring Utilities
Hardware Support
Headless Management
Internet Browser
Multimedia
Common NetworkManager submodules
Printing Client
Server product core
Standard
Transaction Summary
======================================================================================================================================================================================================
Install 202 Packages
Upgrade 38 Packages
Total download size: 238 M
Is this ok [y/N]: y
Once the appropriate packages are installed, change the default systemd boot target to graphical.target
.
systemctl set-default graphical.target
If you need an immediate switch to the GUI login, then start the graphical.target:
systemctl isolate graphical.target
Conclusion
Once the “X Window System” and “Gnome GUI” packages are removed on your CentOS, Rocky, or AlmaLinux system you will not be able to run any UI based applications on the system. For minimal server setup requirements this is key since it frees up resources in your machine and gives optimal server performance. It will discourage system users who love using Linux server as a desktop.
Hi, thanks for the article. After removing the GUI I have one “problem”, if I run dnf grouplist now it lists “Server” and “Server with GUI” under installed. I tried the dnf groupremove “Server with GUI” , but it just says “Done, nothing to do”. Is there a way to fix the list ?
After a reboot?
No, it stays..