How to Check your Ubuntu Version

In this guide, we will demonstrate how to check the version of Ubuntu you are running using the terminal.

Checking your Ubuntu Version

If you are using an Ubuntu system for the first time, it can be helpful to know what version of Ubuntu you are running.

This is helpful as different Ubuntu versions can utilize and support different software that makes configuring the system slightly different.

Canonical pushes out a new release of Ubuntu every six months. These releases can feature anything from minor to significant changes.

Every two years, Canonical will mark a release for long-term support. These versions remain supported for 5 years and are what most servers should be utilizing.

Within this guide, you will learn how you can use the terminal to determine what version of Ubuntu you are running.

Checking the Ubuntu Version using the Terminal

The terminal is one of the fastest and easiest ways to check what version of Ubuntu you are running. Instead of going through numerous menus that might change from release to release, you can use a single command.

Over the following sections, we will show you five different methods you can use within the terminal.

Before you get started, if you are using the desktop flavor of Ubuntu, you can open the terminal easily by pressing CTRL + ALT + T on your keyboard.

Using lsb_release to Get the Ubuntu Version from the Terminal

For the first method, we are going to show you how to utilize the lsb_release command to retrieve the Ubuntu version number. This tool is super easy to use and will get you all of the information you require.

The lsb_release software will display information about the current operating system, such as its codename, description, and release version.

Being part of the Linux Standard Base (LSB) means that this tool should be available on most newer versions of Ubuntu.

1. To get the lsb_release tool to output your Ubuntu version in the terminal, all you need to do is use the following command.

By utilizing the “-a“, argument we are telling the tool to output all available release information.

lsb_release -a

2. From this command, you should end up seeing something like we have below.

This text tells you all you need to know about your current Ubuntu version.

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.1 LTS
Release:        Ubuntu 20.04
Codename:       focal
  • Distributor ID: – Typically, this value is the name of the operating system provider.

    As we are running an Ubuntu operating system, this value should be “Ubuntu“.
  • Description: – In the case of Ubuntu, the description usually holds the long- form version name.

    In our example above, you can see that we are running Ubuntu 20.04.1, which is an LTS (Long term support) release.
  • Release: – Ubuntu uses the release value to only reference the major version number.

    The value of this for our example is “Ubuntu 20.04

    If you were running an older version of Ubuntu, such as 18.04.5 LTS, this value would be “Ubuntu 18.04“.
  • Codename: – The final version information this tool gives us is the release codename.

    Each major release of Ubuntu is given a codename. Typically the Ubuntu team likes to utilize an animal name as part of their codename.

For example, Ubuntu 20.04 is called Focal Fossa, and Ubuntu 18.04 is called Bionic Beaver.

Getting your Version from the lsb-release File

The lsb_release tool is basically a fancy way of displaying the contents of a file of the same name that is stored within the “/etc/” directory.

This file is actually a great way for getting the raw version of Ubuntu from the terminal. All you need to do is use the cat command as we will show you below.

1. Using the cat command, we can print the contents of the “/etc/lsb-release” file to the terminal.

Use the command below to output the contents of the file to the terminal.

cat /etc/lsb-release

2. Below is an example of what you should see displayed in the terminal. This data

If you have used the lsb_release command before, you will notice that the results are similar. This data contains your Ubuntu version, codename, and even distribution name.

If you want the full version name, then you will want to look at “DISTRIB_DESCRIPTION” otherwise look at “DISTRIB_RELEASE” for the shorthand version.

DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=20.04
DISTRIB_CODENAME=focal
DISTRIB_DESCRIPTION="Ubuntu 20.04.1 LTS"

Using the /etc/os-release File to Get the Ubuntu Version in the Terminal

If the previous two methods didn’t get what you needed, we can instead look at the contents of the “/etc/os-release” file.

This file was introduced as a part of the systemd system and service manager. As Ubuntu only started using systemd in version 16.04, this method will only work for newer releases.

1. Luckily, using the “/etc/os-release” file is a super easy way to get your Ubuntu version from the terminal. We can simply use the cat command to dump the contents of the file.

Run the following command on your Ubuntu device to output the version information from the file.

cat /etc/os-release

2. By using this command, you should see the following version information appear within the terminal.

NAME="Ubuntu"
VERSION="20.04.1 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.1 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal

This method will provide you with a lot of information about the version of Ubuntu you are running. It even includes links to the support pages and the Ubuntu home page.

The two values that you will be most interested in is “PRETTY_NAME” and “VERSION_ID“.

  • PRETTY_NAME: This value will provide you the full version name, including whether you are using an LTS release.
  • VERSION_ID: You can use this value to see just the major version of Ubuntu that you are running. If you are following a tutorial this is typically the only value you will need.

Retrieving your Ubuntu Version Using hostnamectl

The final method that we are covering is using the hostnamectl command to get your Ubuntu version. Typically, this tool is used to provide you information about your system’s hostname, but it also provides additional information.

Please note that this tool will only provide the information we need on Ubuntu 16.04 and newer, so please try the other methods first.

1. Using the hostnamectl command to get your version of Ubuntu is a straightforward process.

To output the version information of your system, all you must do is use the command below.

hostnamectl

2. From this command, you should end up getting a result as we have below.

The only thing that we are interested in from this result is the “Operating System:” value. This value tells you everything you need to know about the version of Ubuntu you are running.

From our example above, you can see that we are currently running Ubuntu 20.04.1 LTS on our system.

   Static hostname: pimylifeup
         Icon name: computer
           Chassis: computer
        Machine ID: 0266759ccc6d42aaa421677f7683aad7
           Boot ID: a0cf74546c254e668a59821653736478
  Operating System: Ubuntu 20.04.1 LTS
            Kernel: Linux 5.8.0-40-generic
      Architecture: x86-64

Conclusion

Hopefully, by this stage, you will have a good understanding of how you can easily get the version of Ubuntu that you are running while using the terminal

There are various methods you can use to get the version number, with each being reasonably easy to use and providing all the information that you require.

If you have run into issues with finding out what release of Ubuntu you are running, please drop a comment below.

Also, be sure to check out our other Linux and Ubuntu guides.

Leave a Reply

Your email address will not be published. Required fields are marked *