I am asking question after googling and I tried multiple solution but need a specific answer.

I have logged in another pc with SSH and I need to know that the OS distribution is server or desktop.

I have tried following command and its output:

lsb_release -a

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 12.04.5 LTS
Release:    12.04
Codename:   precise

Second Command

cat /proc/version

Linux version 3.5.0-61-generic (buildd@toyol) (gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5) ) #90-Ubuntu SMP Sun Apr 26 11:23:53 UTC 2015

Not at all duplicate with this

How to check if ubuntu desktop or server is installed?

  • @P.-H.Lin that didnt even solve a problem, did you get the issue Apr 19 '16 at 6:21
  • Why you want to know it? The only difference is the X related package, but you can still remove it from a desktop image or install it on a server image.
    – P.-H. Lin
    Apr 19 '16 at 6:23
  • @P.-H.Lin My application depends on server distribution and it not working on desktop so need to check before running application, I know there is not any diff between so far as same distribution is there Apr 19 '16 at 6:30
  • Can you explain why it doesn't work when a desktop environment is installed?
    – JanC
    Apr 19 '16 at 18:31

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 (){

    '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

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?

  • There are also other desktop environments outside the default one, so it might be necessary to look for some other packages too (assuming it is relevant at all, as you mention at the end).
    – JanC
    Apr 19 '16 at 18:44

you should try the following step 1: type dpkg --list this will show you all installed packages (it will be a lot) step 2: scroll up or down to find any *-session packages, i believe they are the sources of a desktop

Good luck!

Not the answer you're looking for? Browse other questions tagged or ask your own question.