To find the version/codename of Ubuntu distribution 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.