Check if there is a graphical environment installed from the console

Next Kickoff on the KDE desktop

It is likely that you are connected to a server remotely and you need to know if the system where you are has a desktop environment installed or if you can only work from the console. Or, it is likely that you have also had to manage a local computer in which you already have a text mode session started and you do not know if there is a desktop environment installed

In any case, there are various methods to be able to know if there is a graphical environment installed from the console, with a few simple commands that will give you details about the existence or not of an environment. In addition, they are quite simple methods ...

Method 1

From the CLI, you can check if there is a GUI on the system using the installation files and directories that this type of desktop environment uses. For example:

<br data-mce-bogus="1">

ls /usr/bin/*session

With that command, you will list the content of / usr / bin / * session. And if you get any results in the output, you will know that there is indeed a desktop environment installed. For example, depending on whether you are GNOME, KDE Plasma, etc., it may vary in the result, but it could be / usr / bin / gnome-session, / usr / bin / mate-session, / usr / bin / lxsession, / usr / bin / icewm-session,…

Method 2

Other similar method as above it would go through listing the contents of another directory on the system and waiting for a result. In this case it would be:

ls /usr/share/xsessions/

ls /usr/share/wayland-sessions

You can try both commands, one for the graphic sessions that use the graphical server X and the second for the Wayland protocol. If you get a result, then you can deduce that there is a desktop environment installed.

Method 3

Although there are many more methods, another of the existing ones that can be practical is to use a variable to query the desktop environment that is installed in a distro, returning the name of it. For example:

echo $XDG_CURRENT_DESKTOP

But be careful, use the method you use to consult, that these files are there does not mean that it is functional ...


Leave a Comment

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

*

*

  1. Responsible for the data: AB Internet Networks 2008 SL
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   ROMSAT said

    $ echo $ XDG_CURRENT_DESKTOP
    ubuntu: GNOME