"Almost" the same question has been asked here:
Know Ubuntu Distribution server or desktop
I would like to post my answer here as well because it has a few new hints how to check if your on a desktop or server edition.
As mentioned in previous posts, it's not easy to determine if you use a desktop or server edition because all package can be installed or removed.
If you are in a consistent and predictable environment it shouldn't be very difficult to determine if desktop or server.
I use only ubuntu-desktop (vanilla) or ubuntu server. For me the dpkg -l ubuntu-desktop
it's a very reliable method to determine if its a desktop or server.
As mentioned in the linked post, it's not easy to determine if you use a desktop or server edition because all packages can be installed or removed.
Here is my function I use for my scripts.
Basically it checks if xserver-common or xwayland are installed. If one of them is installed it means its an desktop system.
#!/usr/bin/env bash
check_if_desktop (){
IS_DESKTOP="false"
displayManager=(
'xserver-common' # X Window System (X.Org) infrastructure
'xwayland' # Xwayland X server
)
for i in "${displayManager[@]}"; do
dpkg-query --show --showformat='${Status}\n' $i 2> /dev/null | grep "install ok installed" &> /dev/null
if [[ $? -eq 0 ]]; then
IS_DESKTOP="true"
fi
done
}
Here are a few other things to check:
By default the server edition uses the classic /etc/network/interfaces
, while the desktop edition operates with Network Manager, so check if Network Manager is installed
dpkg -l network-manager
Or run the command nmcli (the command line tool for NM)
if you get a message like this:
The program 'nmcli' is currently not installed. You can install it by typing:
sudo apt-get install network-manager
the probability is high that you are on a server edition.
But keep in mind, you can modify a server to operate with NM.
Use the following command to determine if desktop components are installed
dpkg -l ubuntu-desktop
On a Server you will get a message like this:
dpkg-query: no packages found matching ubuntu-desktop
On a Desktop you will get a message that tells you which version is installed
Check for other packages that are typically found on a desktop:
dpkg -l unity (gnome, mate and so one) # Desktop environments
dpkg -l compiz (E17, fluxbox and so one) # Window manager
dpkg -l xorg # X window server
or use:
dpkg-query --show --showformat='${Status}\n' *packagename* 2> /dev/null | grep "install ok installed"
check if the X server is running:
ps -e | grep X
sudo netstat -lp | grep -i Xorg
Check for services that are only available on a desktop:
It depends on your Ubuntu version how to check the services:
sudo service *servicename* status # on SysVinit
sudo status *servicename* # on Upstart
systemctl status *servicename*.service # on systemd
typical services are:
- lightdm
- x11-common
- gnome-shell
and some others that are associated with certain derivatives
My application depends on server distribution
Even if it doesn't make any sense to run a server application on a desktop edition, there shouldn't be any issues with installing all the dependencies for your application on the desktop edition and make it working.
Can you elaborate on this why it depends on the server distro?