The other day one of our blog follower tried to install Katoolin and it broke his Ubuntu machine. He couldn't get past the login screen. He somehow managed to recover his broken Ubuntu system without reinstalling it. However, this time his machine was booting on CLI mode only. It seems like the graphical DE has gone, but he is not so sure. He asked me that how could he find if GUI is there or not at this point. If you are ever in this situation, here are a few tips to check if GUI is installed in Linux from commandline.
Check If GUI Is Installed In Linux From Commandline
There are couple ways to detect whether your Linux system has GUI installed. Please note that all of these methods will only show if is GUI installed or not. It will not, however, help to identify if GUI is running or not.
All steps given below are tested under Ubuntu 20.04 LTS desktop and server editions.
The first method is to make sure if there is any X session installed on your system. To do so, run:
$ ls /usr/bin/*session
If your Linux system has any GUI session, it should display something like below:
/usr/bin/dbus-run-session /usr/bin/gnome-session-custom-session /usr/bin/gnome-session
As you see in the above output, my Ubuntu has GNOME Desktop Environment installed.
- If your system has MATE installed, it will print
- For LXDE, it will return
If a Linux doesn't has any GUI installed in it, you will see an output like below:
This command works only on Debian-based systems, such as Ubuntu, Linux Mint, Pop!_OS etc. If your system is RPM-based systems like Fedora, RHEL, you will see the following error message:
ls: cannot access '/usr/bin/*session': No such file or directory
In that case, refer the following methods.
The second method to detect if there is any GUI installed on your system is to check the presence of X server with
$ type Xorg
On Linux system with GUI installed, you will see the following output:
Xorg is /usr/bin/Xorg
On CLI-only Linux systems, the output should be:
-bash: type: Xorg: not found
The another method to verify if GUI installed on your Linux system is to check the contents of
/usr/share/xsessions/ directory with
$ ls /usr/share/xsessions/
Sample output on Ubuntu Linux GUI system:
Sample output from Ubuntu Linux CLI-only machine:
ls: cannot access '/usr/share/xsessions/': No such file or directory
This is exclusively for Debian-based systems. You can also check if GUI is installed or not with
grep commands like below:
$ dpkg -l | grep xserver
This command lists all installed X11 and xserver related packages.
Sample output from Ubuntu Linux GUI system:
ii x11-xserver-utils 7.7+8 amd64 X server utilities ii xserver-common 2:1.20.9-2ubuntu1.2~20.04.1 all common files used by various X servers ii xserver-xephyr 2:1.20.9-2ubuntu1.2~20.04.1 amd64 nested X server ii xserver-xorg 1:7.7+19ubuntu14 amd64 X.Org X server ii xserver-xorg-core 2:1.20.9-2ubuntu1.2~20.04.1 amd64 Xorg X server - core server ii xserver-xorg-core-hwe-18.04 3:14.5 amd64 Transitional package for xserver-xorg-core-hwe-18.04 ii xserver-xorg-hwe-18.04 3:14.5 amd64 Transitional package for xserver-xorg-hwe-18.04 ii xserver-xorg-input-all 1:7.7+19ubuntu14 amd64 X.Org X server -- input driver metapackage ii xserver-xorg-input-libinput 0.29.0-1 amd64 X.Org X server -- libinput input driver ii xserver-xorg-input-wacom 1:0.39.0-0ubuntu1 amd64 X.Org X server -- Wacom input driver ii xserver-xorg-legacy 2:1.20.9-2ubuntu1.2~20.04.1 amd64 setuid root Xorg server wrapper ii xserver-xorg-video-all 1:7.7+19ubuntu14 amd64 X.Org X server -- output driver metapackage ii xserver-xorg-video-all-hwe-18.04 3:14.5 amd64 Transitional package for xserver-xorg-video-all-hwe-18.04 ii xserver-xorg-video-amdgpu 19.1.0-1 amd64 X.Org X server -- AMDGPU display driver ii xserver-xorg-video-amdgpu-hwe-18.04 3:14.5 amd64 Transitional package for xserver-xorg-video-amdgpu-hwe-18.04 ii xserver-xorg-video-ati 1:19.1.0-1 amd64 X.Org X server -- AMD/ATI display driver wrapper ii xserver-xorg-video-ati-hwe-18.04 3:14.5 amd64 Transitional package for xserver-xorg-video-ati-hwe-18.04 ii xserver-xorg-video-fbdev 1:0.5.0-1ubuntu1 amd64 X.Org X server -- fbdev display driver ii xserver-xorg-video-fbdev-hwe-18.04 3:14.5 amd64 Transitional package for xserver-xorg-video-fbdev-hwe-18.04 ii xserver-xorg-video-intel 2:2.99.917+git20200226-1 amd64 X.Org X server -- Intel i8xx, i9xx display driver ii xserver-xorg-video-nouveau 1:1.0.16-1 amd64 X.Org X server -- Nouveau display driver ii xserver-xorg-video-qxl 0.1.5+git20200331-1 amd64 X.Org X server -- QXL display driver ii xserver-xorg-video-qxl-hwe-18.04 3:14.5 amd64 Transitional package for xserver-xorg-video-qxl-hwe-18.04 ii xserver-xorg-video-radeon 1:19.1.0-1 amd64 X.Org X server -- AMD/ATI Radeon display driver ii xserver-xorg-video-vesa 1:2.4.0-2 amd64 X.Org X server -- VESA display driver ii xserver-xorg-video-vesa-hwe-18.04 3:14.5 amd64 Transitional package for xserver-xorg-video-vesa-hwe-18.04 ii xserver-xorg-video-vmware 1:13.3.0-3 amd64 X.Org X server -- VMware display driver
On Ubuntu server without GUI, you will only see a few X server related packages:
rc x11-xserver-utils 7.7+8 amd64 X server utilities ii xserver-common 2:1.20.9-2ubuntu1.2~20.04.1 all common files used by various X servers
However, this is not so reliable method. Because, you could have installed DE without using package managers like
apt. In such cases, this will not return any results. Even if you installed and then removed the X server, it will still show that X server is installed.
How to find which Desktop Environment you are using in Linux?
This is a bonus method. We can easily find the current Desktop environment in our Linux GUI system using the following command:
$ echo $XDG_CURRENT_DESKTOP ubuntu:GNOME
As you see in the output, I am using Ubuntu GNOME desktop environment. If you don't have any DE, you will see nothing.
Hope this helps.
Featured image by erfouris studio from Pixabay.