The Ubuntu operating system is a good alternative for Windows and macOS users. It is an open-source operating system available free to all. While working, we need to install multiple third-party software, which is available for version-specific. In that case, you need to find the Ubuntu version you are using.
The lsb-release is the standard package for reporting the version on Ubuntu systems. Which is basically written in the Python programming language. It provides lsb_release command-line tool to check Ubuntu version and other useful details.
In this tutorial, you will learn various options to get the Ubuntu version details with the command line.
How to Check Ubuntu Version
/etc/lsb-release is the main file, which contains the Ubuntu version details. You can view /etc/lsb-release file content to fine Ubuntu version and version-specific details.
Open a terminal on your system and type:
DISTRIB_ID=Ubuntu DISTRIB_RELEASE=20.04 DISTRIB_CODENAME=focal DISTRIB_DESCRIPTION="Ubuntu 20.04.1 LTS"
lsb-release command to view Ubuntu version details. This utility also reads the content from /etc/lsb-relese file.
Run the lsb_release command with
-a option to view all details.
No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 20.04.1 LTS Release: 20.04 Codename: focal
The above output shows that your system is running with Ubuntu 20.04.1 LTS system and the codename is focal.
Check Specific Details
You can also use other command-line options to fetch specific details about the Ubuntu versions. Use the following commands on the terminal to view specific Ubuntu version details.
- View distribution name
## Output: "Distributor ID: Ubuntu"
## Output: "Ubuntu"
- Show the Ubuntu version description
## Output: "Description: Ubuntu 20.04.1 LTS"
## Output: "Ubuntu 20.04.1 LTS"
- Show the release number version
## Output: "Release: 20.04"
## Output: "20.04"
- View Ubuntu codename
## Output: "Codename: focal"
## Output: "focal"
-s parameter with above commands to view short version ouput.
How to Find Ubuntu Version in a Shell Script
Shell scripts play an important role in system administration tasks. They help us to automate tasks easily. While writing shell scripts, you may be required to check the Ubuntu version details before executing a set of commands. Here is a sample shell script to check the Ubuntu version to run a set of commands.
if [ $code == "focal" ]; then
# Run code specifc to Ubuntu 20.04
elif [ $code == "bionic" ]; then
# Run code specifc to Ubuntu 18.04
elif [ $code == "xenial" ]; then
# Run code specifc to Ubuntu 16.04
# No matching version found
Ubuntu Release Cycle
Ubuntu release a new version every 6 months. All the Ubuntu version numbers follow the “YY:MM” format. For example, the last release of Ubuntu is 21.04 (Apr 2021).
Every 2 years a Long Term Support (LTS) version releases by the team, which supports updates for the next 5 years. All the production servers are suggested to use the LTS version as its most stable release.
Recent Ubuntu Versons:
- Ubuntu 21.04
- Ubuntu 20.10
- Ubuntu 20.04 LTS
- Ubuntu 19.10
- Ubuntu 19.04
- Ubuntu 18.10
- Ubuntu 18.04 LTS
This tutorial described how to find running Ubuntu system version details on the command line. Also provides instructions to verify the version before running commands in shell scripts.