Home  »  Blog  »  How to Check Ubuntu Version Using Command Line

How to Check Ubuntu Version Using Command Line

ubuntu

In this guide, I will show you how you can easily check which version of Ubuntu you are currently running on your machine. There are 2 main ways you can achieve this

    1. Using the Terminal
    2. Using the GUI

So let’s get started and see how you can check which version of Ubuntu runs on your machine. But, Today I will be showing you on how to check ubuntu version using command line only.

Using Terminal

To check the version, Open your terminal and run the following command.

lsb_release -a

Output

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 16.04.5 LTS
Release:        16.04
Codename:       xenial

To be more specific you can also run

lsb_release -r

Output

Release:        16.04

Another way you can retrieve the version of your Ubuntu system is by running

cat /etc/lsb-release

Output

DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04.5 LTS"

To gather more detailed information run

cat /etc/*release

Output

DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04.5 LTS"
NAME="Ubuntu"
VERSION="16.04.5 LTS (Xenial Xerus)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 16.04.5 LTS"
VERSION_ID="16.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
VERSION_CODENAME=xenial
UBUNTU_CODENAME=xenial

In addition, this can also come in handy

# cat /etc/os-release

Output

NAME="Ubuntu"
VERSION="18.04.1 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.1 LTS"
VERSION_ID="18.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=bionic
UBUNTU_CODENAME=bionic

To get information about the kernel and architecture run

uname -a

Output

Linux ubuntu-16-04-1 4.4.0-57-generic #78-Ubuntu SMP Fri Dec 9 23:50:32 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

Also, the hostnamectl command can help you get the version of Ubuntu you are running

hostnamectl

This will give more detailed information such as Operating System, kernel, Architecture and in case the system is virtualized, it will display virtualization type and chassis.

Output

 Static hostname: ubuntu-16-04-1
         Icon name: computer-vm
           Chassis: vm
        Machine ID: bc429e3618b24cebbb4ba8e951e20250
           Boot ID: 9b1912bef4064d1cb449a009c31fc1c6
    Virtualization: kvm
  Operating System: Ubuntu 16.04.5 LTS
            Kernel: Linux 4.4.0-57-generic
      Architecture: x86-64

Lastly, you can run this command on Terminal to give you the version of Ubuntu that you are running.

awk '/^Description: Ubuntu [0-9]/ {print "Ubuntu",$3; exit;}' /usr/share/python-apt/templates/Ubuntu.info

Output

Ubuntu 16.04

Conclusion

I hope you known which version of ubuntu you are currenlty running on your machine . If you have any queries, suggestions, comments, please do comment down below. If you have any questions, suggestions, feedback please don’t hesitate to write them in the comment box below because it will help us to improve or correct our contents.

Also Read: How To Install PyCharm In Ubuntu 18.04 and Linux Mint 19

Kool Arpan is a Tech Enthusiastic who loves blogging and writing articles on technology. He is a very humble in person. He loves sharing knowledge to the others by any means and medium.

Start a discussion