Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a set of functions in bash script which I want to run only on particular flavors of Ubuntu. For example, I want to run the following if I am running Unity:

gsettings set com.canonical.indicator.datetime show-week-numbers true

but the following if I am running Ubuntu GNOME:

gsettings set show-weekdate true

and similarly, different commands for different flavors of Ubuntu.

I have tried to see the contents of /etc/os-release, but it doesn't give any information about the flavor of Ubuntu. The following is when run on Ubuntu GNOME:

$ cat /etc/os-release
VERSION="14.04, Trusty Tahr"
PRETTY_NAME="Ubuntu 14.04 LTS"

Is it possible to know which recognized flavor I am running using terminal? I would prefer a solution which works out of the box, without installing any other packages for both live and installed environments. Looking for what packages are installed is a possibility, but I would prefer not to go that route, although you are welcome to give an answer in that direction.

share|improve this question
Do you want to know the Ubuntu flavor installed or the desktop environment you are currently running? – terdon Apr 23 '14 at 1:28
@terdon I am looking for the flavor I've installed/running in a Live Environment.. – Aditya Apr 23 '14 at 9:04
I understand, I just can't imagine why that would ever be useful. The flavor is just the set of packages installed by default, it does not say anything about what you actually have installed. I can install KDE on Xubuntu for example, so why would it be useful to know that I'm running Xubuntu and not Kubuntu? – terdon Apr 23 '14 at 11:07
@terdon I just wanted to script it that way, but yes looking at what desktop environment I am running would be more useful. – Aditya Apr 23 '14 at 12:54
@Aditya: Maybe not the flavor... but you can read the XDG_CURRENT_DESKTOP variable to know what the current desktop enviroment is running eg: Unity,GNOME,XFCE,KDE – Roman Raguet May 12 '14 at 13:10

This is the command that I use. It works for me all the time:

cat /var/log/installer/media-info 

Output (my system) Correctly tells that I am running Kubuntu

Kubuntu 14.04 LTS "Trusty Tahr" - Beta amd64 (20140326.2)
share|improve this answer
It says This to me. – Aditya May 12 '14 at 12:51
OP asked for Ubuntu flavours(unity,gnome) – Avinash Raj May 12 '14 at 13:09
@AvinashRaj Something like that would have been fine as well :) – Aditya May 12 '14 at 13:19
This is a good way to tell about the installation media used, not the currently running release. If you've been applying all your updates you are no longer running the Beta release – Elder Geek May 14 '14 at 21:01

Maybe not a flavor like Kubuntu, Xubuntu, Lubuntu etc. Because as Oli & terdon comments you can install Kubuntu but running XFCE as Desktop.

So, you can get the value of the enviroment variable XDG_CURRENT_DESKTOP to know what the current desktop is running.



The values of the variable could be Unity,GNOME,XFCE,KDE,LXDE,Pantheon (Elementary os).

Hope this helps.

share|improve this answer
Although the question was about recognized flavors and this won't let me know if I am running Edubuntu, UbuntuKylin, Mythbuntu, UbuntuStudio or other recognized flavors; but this would help me solve the problem I was trying to solve. So, +1 for the answer, but I am not really sure if I want to accept it or not. – Aditya May 12 '14 at 13:48
@Aditya: I understand. Perhaps the title of your question could be "Is it possible to know which Desktop enviroment I am running using terminal?". according to the content of you question you want to set with gsetting if I'm running Unity or Gnome etc (Desktops) not Flavors. maybe you can combine with the cshubhamrao's answer cat /var/log/installer/media-info. worked for me in virtual machines Kubuntu, Ubuntu Gnome, Ubuntu, Xubuntu. (installed not live) – Roman Raguet May 12 '14 at 14:15
Simple and elegant. I like it. – Elder Geek May 14 '14 at 20:49

Set both. Set everything. Fire and forget.

The settings are exclusive enough not to affect other things so it should be safe... And it's a lot, lot easier to do than needing to work out what's being run... Working out what's installed is possible but that isn't an indication of what the user actually uses.

share|improve this answer
Yes, the commands don't seem to have any side-effects when run on the environment where they are not intended to be run, but isn't there any file from which I can extract the information of the flavor I am running? – Aditya Apr 21 '14 at 15:49
Even if there was a way (and there almost certainly is) that doesn't guarantee the user is in that environment. You can install gnome and KDE on Ubuntu and it still be Ubuntu. – Oli Apr 21 '14 at 16:00

The following if will show you if you are running Unity or not:

if [[ "$(ps -ef | grep unity | grep $USER | grep -v grep)" =~ "unity" ]]; then 
    echo "I'm running Unity"; 

In the same way you can check if you are running GNOME or other flavors. The important thing is what (part) name of the process you use for first grep. You must distinguish a specific process which run all the time only in the flavor about which you are interested.

share|improve this answer
I like the use of ps and grep here. However, distinguishing a specific process to apply to a specific flavor will probably be a bit difficult for the average user. – Elder Geek May 14 '14 at 20:57

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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