How To Check Ubuntu Version In Bash Using Terminal

Checking the Ubuntu version in Bash is important for installing various software and applications. Here are the commands you can use to get the Ubuntu version on an Ubuntu server or check the Ubuntu version from the terminal.

Check the Ubuntu version in Bash (Terminal).

Before we begin, you must note that there are two types of Ubuntu releases:

  1. Interim Ubuntu Release: Ubuntu 22.04.3 LTS (Jammy Jellyfish) and Ubuntu 20.04.6 LTS (Focal Fossa)
  2. LTS Ubuntu Release – Ubuntu 23.04 (Lunar Lobster)

The difference between the Interim and LTS release is the fact that each Ubuntu LTS is maintained for 10 years total: 5 years of standard support + 5 years of ESMm, whereas the Interim releases are maintained for just 9 months.

Moving on, there are various ways to check the Ubuntu version using the terminal command line or bash. I have listed four different commands to check the Ubuntu version using the terminal. Read below to learn about these commands.

1. lsb_release Command

The lsb_release command provides certain LSB (Linux Standard Base) and distribution-specific information. To know the Ubuntu version, simply run the following command in the terminal:

$ lsb_release -a

When you execute the command with -a argument, you get complete details about the OS that is currently installed on the system. You can see information such as LSB modules, distributor id, description, release, and codename.

It must be noted that when no options are given with the command lsb_release, the -v option is assumed, which stands for version. The command lsb_release when executed with -v or –version it shows the version of the current installation. 

If you want to know only the Ubuntu version (OS version), simply run the lsb_release command with the option -d. It will then only display the description information that contains the OS version (Ubuntu version in our case).

2. /etc/os-release Command

The os-release file contains operating system identification data. The OS release contains data that is defined by the operating system vendor. It shows information such as name, version, id, id_like, pretty_name, version_id, home_url, support_url, bug_report_url, version_codename, and ubuntu_codename.

The name tab shows the OS name, and the version tab of the OS-release file shows the OS version. These are the strings identifying the operating system. The command also shows the version_codename and ubuntu_codename.

To use the command to get details about the Ubuntu version, simply run the following command in the terminal (CTRL + ALT + T):

$ cat /etc/os-release

3. /etc/issue Command

The /etc/issue file is the prelogin message and identification file of the Linux OS. This text file contains a message or system identification to be printed before the login prompt. The command cat /etc/issue only shows the version of Ubuntu.

To use the command to get details about the Ubuntu version, simply run the following command in the terminal (CTRL + ALT + T):

$ cat /etc/issue

4. hostnamectl Command

This is not your average command to check the OS version. The hostnamectl command is employed to manage the system hostname. It is capable of querying, changing, and updating the system hostname and its related settings.

While the hostnamectl command is primarily used to set hostname, you can also check the Ubuntu version using this command.

Another great thing about the command is, apart from the version of the OS, the command also displays other details such as static hostname, icon name, chassis, machine id, boot id, operating system, kernel and architecture.

The command can be used to obtain information about the Ubuntu version by running the following command in terminal (CTRL + ALT + T).

$ hostnamectl

How to Check Ubuntu Version Through GUI (System Settings)

If you do to wish to run commands in terminal, you can know the OS version easier way, using GUI. To get details about OS version, simply follow the steps given below:

  1. Open the Ubuntu System Settings.
  2. Go to the Details section by scrolling to the bottom.
  3. To view the Ubuntu version, click on it.

That’s all folks. We are confident that this article fulfills its purpose and you can now check your Ubuntu version through the terminal.

Author: Team Linux Ledger

The team of Linux experts and open source enthusiasts who are passionate about sharing their expertise with you through in-depth tutorials, news, and updates on various aspects of open source in general and Linux in particular A team that helps you become a better Linux user.

Leave a Comment