There are many cases where you need to run some batch processing jobs which can vary across different Ubuntu releases (e.g., Quantal Quetzal, Raring Ringtail, Saucy Salamander, Trusty Tahr, Utopic Unicorn). For example, you may want to download a source package which is available as multiple Ubuntu release versions, or you may want to access Ubuntu repositories for different releases. Often times, available source packages or repositories may be named after the "codename" or "nickname" (e.g., quantal, raring, saucy, trusty, utopic) of Ubuntu releases.
If you need to find the version/codename of your Ubuntu system from the command line, you can use lsb_release command which displays distribution-specific information.
The following shell script snippet demonstrate how to store the version and codename of Ubuntu in two different variables.
#!/bin/sh version=`lsb_release --release | cut -f2` codename=`lsb_release --codename | cut -f2` echo $version echo $codename
lsb_release command also works on other Linux distros, including Debian, CentOS, Fedora and OpenSUSE.
Subscribe to Ask Xmodulo
Do you want to receive Linux related questions & answers published at Ask Xmodulo? Enter your email address below, and we will deliver our Linux Q&A straight to your email box, for free. Delivery powered by Google Feedburner.
Did you find this tutorial helpful? Then please be generous and support Xmodulo!