Page 1 of 1
[RESOLVE] Find the name of Ubuntu version with Mint
Posted: Wed Mar 06, 2013 3:18 pm
by percherie
Hi,
I use Mint and I want a solution for the name Ubuntu version that matches my version Mint
Nadia For example, I want to get Quantal. It is for use in the command line. Currently the following commands can not function because of the use of $lsb_release -sc
For exemple :
Code: Select all
echo "deb http://download.virtualbox.org/virtualbox/debian `lsb_release -sc` contrib"
OR
Code: Select all
wget --output-document=/etc/apt/sources.list.d/medibuntu.list http://www.medibuntu.org/sources.list.d/$(lsb_release -cs).list
OR
Code: Select all
echo "deb http://josm.openstreetmap.de/apt `lsb_release -sc` universe #JOSM" | sudo tee -a /etc/apt/sources.list && wget -q http://josm.openstreetmap.de/josm-apt.key -O- | sudo apt-key add - && sudo apt-get update
Re: Find the name of Ubuntu version with Mint
Posted: Wed Mar 06, 2013 5:46 pm
by karlchen
Hello, percherie.
On an absolutely up-to-date Mint13 here, there is a file named /etc/os-release. It has been introduced by some Ubuntu update which turned the underlying Ubuntu into 12.04.2. The content of the file /etc/os-release reads
Code: Select all
NAME="Ubuntu"
VERSION="12.04.2 LTS, Precise Pangolin"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu precise (12.04.2 LTS)"
VERSION_ID="12.04"
returns the string
maya.
So in order to get the string
precise which is the codename of the Ubuntu version which Maya has been built upon, I can use the following command:
Code: Select all
grep "PRETTY_NAME" /etc/os-release | awk '{ print $2 }'
It returns the string
precise here.
Provided the same file /etc/os-release exists on Nadia as well, the command should return
quantal in your case.
I cannot check right now because I am on Mint 13. But I will definitely check next time I boot up Nadia.
HTH,
Karl
Re: Find the name of Ubuntu version with Mint
Posted: Wed Mar 06, 2013 5:55 pm
by percherie
Thank you
My english it's light but i am all understand
Re: [RESOLVE] Find the name of Ubuntu version with Mint
Posted: Thu Mar 07, 2013 6:14 pm
by karlchen
Hello, percherie.
As promised, here is the result of the test done on my Mint 14 system:
Code: Select all
$ lsb_release -sc
nadia
$ grep "PRETTY_NAME" /etc/os-release | awk '{ print $2 }'
quantal
$
So the command works provided the file /etc/os-release is up-to-date.
Cheers,
Karl
Re: [RESOLVE] Find the name of Ubuntu version with Mint
Posted: Thu Mar 07, 2013 6:57 pm
by percherie
Thank you karl for your test (and new install of mint)
Re: [RESOLVE] Find the name of Ubuntu version with Mint
Posted: Wed Oct 02, 2013 1:48 pm
by mirage59
Hello all,
On Olivia, the previous solution doesn't work for me
(Ubuntu version : 13.04, Raring Ringtail)
so to install JOSM with the openstreetmap.de repository and
stay with a recent version of this amazing tool you can use these commands :
Code: Select all
#Add the key
wget -q http://josm.openstreetmap.de/josm-apt.key -O- | sudo apt-key add -
#Add the repository
echo "deb http://josm.openstreetmap.de/apt `grep "VERSION=" /etc/os-release | tr ',' '\n' | tr '"' ' ' | cut -d' ' -f2 | tail -1 | tr [:upper:] [:lower:]` universe" | sudo tee -a /etc/apt/sources.list
NB : This command isn't elegant but I'm not an awk guru and this have worked fine for me.
Mirage59
Re: [RESOLVE] Find the name of Ubuntu version with Mint
Posted: Fri Oct 04, 2013 2:05 pm
by mirage59
Hi all,
I have read a little about awk so this is my prettier solution :
Code: Select all
#Add the key
wget -q http://josm.openstreetmap.de/josm-apt.key -O- | sudo apt-key add -
#Add the repository
echo "deb http://josm.openstreetmap.de/apt `grep "VERSION=" /etc/os-release | awk '{ print $2 }' | tr [:upper:] [:lower:]` universe" | sudo tee -a /etc/apt/sources.list
Feel free to improve it
Mirage59
Re: [RESOLVE] Find the name of Ubuntu version with Mint
Posted: Thu Oct 24, 2013 5:13 am
by percherie
mirage59 wrote:Hi all,
I have read a little about awk so this is my prettier solution :
Code: Select all
#Add the key
wget -q http://josm.openstreetmap.de/josm-apt.key -O- | sudo apt-key add -
#Add the repository
echo "deb http://josm.openstreetmap.de/apt `grep "VERSION=" /etc/os-release | awk '{ print $2 }' | tr [:upper:] [:lower:]` universe" | sudo tee -a /etc/apt/sources.list
Feel free to improve it
Mirage59
Thank you is better, i like it
Re: [RESOLVE] Find the name of Ubuntu version with Mint
Posted: Tue Sep 30, 2014 10:59 pm
by Skeptikos
In 14.04 / Linux Mint 17, this no longer works for me.
This is my os-release file:
Code: Select all
NAME="Ubuntu"
VERSION="14.04.1 LTS, Trusty Tahr"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 14.04.1 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/"
Can't get "trusty" out of the PRETTY_NAME= line like Karl did earlier, and mirage's code returns "LTS,".
This is what I used instead, to get the next-to-last word after "VERSION=":
Code: Select all
grep "VERSION=" /etc/os-release | awk '{print $(NF-1)}' | tr [:upper:] [:lower:]
Hopefully this will work for a few more releases, at least, since it won't be confused by the presence or absence of "LTS" in the long-term support releases.
Re: [RESOLVE] Find the name of Ubuntu version with Mint
Posted: Fri Jul 10, 2015 7:05 am
by risimmons
I just came across this today. The simple answer is to use lsb_release -ur / -uc to give upstream information. This works on 17.2 - don't know about other releases;
Code: Select all
12:08:15 ~ $ lsb_release -ur
Release: 14.04
Code: Select all
12:12:12 ~ $ lsb_release -uc
Codename: trusty
Re: [RESOLVE] Find the name of Ubuntu version with Mint
Posted: Sun Jul 31, 2016 6:46 pm
by SiKing
Was just looking for this solution today. On LM-Sarah 'lsb_release -ur' returns "lsb_release: error: no such option: -u".
However, others mentioned the file `/etc/os-release`, but I think you are all using it wrong. The more elegant solution, IMHO, is:
Code: Select all
$ source /etc/os-release
$ echo $UBUNTU_CODENAME
xenial
No need for `grep` or `awk`, just source the file from your script and the call the appropriate variable.