Ubuntu: How can I detect whether Ubuntu server has a GUI installed?



Question:

I am using Ubuntu Server 14.04 LTS. How can I tell whether it has a graphical user interface installed?


Solution:1

Look at /usr/share/xsessions/ directory to see if there are any X sessions available on your Ubuntu:

$ ls /usr/share/xsessions/  openbox.desktop  

which says I've got "openbox" on my machine, it can be "Unity", "Gnome" or anything else for you. If you get nothing, so nothing has been installed.


Extra step:

You can run something like this on that file to see if its binary really exist on your machine and it's not a leftover file:

file $(grep -Po "(?<=^Exec=).*" /usr/share/xsessions/openbox.desktop)  
  • grep -Po "(?<=^Exec=).* returns something similar to: /usr/bin/openbox
  • file will check if that really exist.


Solution:2

you can also use the package manager to search for installed packages. Try looking for the main window managers, or the actual X server package

To see if any KDE packages are installed (kde-baseapps is the meta packages for the absolute minimum for a KDE install, I have kde-full which is a meta to install everything interesting, if kde-baseapps-bin isn't installed, then you don't have KDE at any level), use dpkg -l kde*

apt-cache search unity shows unity8 is the main shell there, it doesnt show up when I run dpkg -l unity* as I don't have it installed.

apt-cache search gnome shows gnome is the main shell there. dpkg -l gnome* shows I don't have that either.

For a more basic setup, you might want to try looking for the package that provides the X server directly: dpkg -l xorg or dpkg -l xserver-xorg or dpkg -l xserver* generally (I have xorg installed).

If /usr/bin/X exists, then you have an X server available, and can run gui apps, locally. There are some very small windows managers (twm, tinywm and others) which don't do much, but are handy if you occasionally need gui facilities (If you don't have a window manager then you cannot resize/maximise or minimise and apps running on X and the window will always sit aligned to the top left most corner of the screen).

Mostly you start a gui (if it's not setup as a daemon) on linux, with the startx or xstartup commands. There are variants kdeinit was the one I remember for kde, you could search for those (probably in /usr/bin or /usr/sbin or use whereis).

However remember you don't need to run X applications locally, you can run X applications over the network, from a remote X terminal (I use cygwin's x-server on Windows for this). For example, I had thunderbird installed on my server farm hosted linux server, without X, simply so I could have it run remotely, to move huge amounts of emails between folders, and only the traffic needed to update the X screen needed leave the server. I've since discovered mutt, but it can be done.

Edit:

I would add that whilst most packages containing an X based application will require packages which amount to expecting you to have X and a windows manager installed with it, they're not essential. For example, I support a number of Linux Servers, without any gui, on which I have qgit installed. It's a graphical tool for reviewing git heirarchy. I can forward my X session to the servers, and run the app on the servers, and it'll display on my desktop. However as discussed you'll not find any of the above stuff installed on the servers (no X, no windows managers). So bear in mind just because you don't have an X server setup on a host, doesn't mean it can't run a gui (it'd just have to be remote).


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »