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 org.gnome.shell.calendar 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 NAME="Ubuntu" VERSION="14.04, Trusty Tahr" ID=ubuntu ID_LIKE=debian PRETTY_NAME="Ubuntu 14.04 LTS" VERSION_ID="14.04" HOME_URL="http://www.ubuntu.com/" SUPPORT_URL="http://help.ubuntu.com/" BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
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.
Answer
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)
Attribution
Source : Link , Question Author : Aditya , Answer Author : cshubhamrao