• Home
  • Ubuntu 20.04
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us
TecAdmin
Menu
  • Home
  • Ubuntu 20.04
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us

How to Check Ubuntu Version with Command or Script

Written by Rahul, Updated on December 6, 2020

The lsb-release is the standard package for reporting the version on Ubuntu systems. Which is basically written in Python programming language.

The lsb-release package provides a command lsb_release used to check Ubuntu version and codename on command line. In this tutorial, you will learn various options to lsb_release command on Ubuntu system.

Check Ubuntu Version

Use -a option to see all version details of Ubuntu system.

Open a terminal (CTRL + ALT + T) on your system and type lsb_release -a to find Ubuntu version details:

lsb_release -a 

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.4 LTS
Release:        18.04
Codename:       bionic

The above output shows that, your system is running with Ubuntu 18.04 LTS system. Its code name is bionic.

Check Specific Details

You can also use other command line options to fetch specific details about Ubuntu system. Use the following commands on terminal to view specific details.

  • View distribution name
     lsb_release -i     ## Distributor ID: Ubuntu 
    
  • Show the Ubuntu version description
     lsb_release -d     ## Description:    Ubuntu 18.04.4 LTS 
    
  • Show the release number version
     lsb_release -r     ## Release:        18.04 
    
  • View Ubuntu codename
     lsb_release -c     ## Codename:       bionic 
    

You can also use -s option with above commands to fetch short details. Like lsb_release -cs command will return bionic only.

Ubuntu Release Cycle

Ubuntu release a new version on every 6 months. All the Ubuntu versions numbers follows “YY:MM” format. For example the last release of Ubuntu was 20.10 (Oct, 2020).

At every 2 years a Long Term Support (LTS) version releases by the team, which supports updates for next 5 years. All the production servers are suggested to use LTS version as its most stable release.

Recent Ubuntu Versons:

  • Ubuntu 20.10
  • Ubuntu 20.04 LTS
  • Ubuntu 19.10
  • Ubuntu 19.04
  • Ubuntu 18.10
  • Ubuntu 18.04 LTS
    • Check Ubuntu Version in Shell Scripts

      Shell scripts plays an important role in system administration. To be a good system administrator, you must be good in writing shell scripts. It helps us to automate daily tasks to complete frequently.

      Sometimes you need to verify the version of Ubuntu server in your shell scripts.

      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      11
      12
      13
      #!/bin/bash
       
      code=$(lsb_release -cs)
       
      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
      else
         # No matching version found
      fi

      Conclusion

      This tutorial described you to how to find running Ubuntu system version details on command line. Also provides instructions to verify the version before running commands in shell scripts.

Share it!
Share on Facebook
Share on Twitter
Share on LinkedIn
Share on Reddit
Share on Tumblr
Share on Whatsapp
Rahul
Rahul
Connect on Facebook Connect on Twitter

I, Rahul Kumar am the founder and chief editor of TecAdmin.net. I am a Red Hat Certified Engineer (RHCE) and working as an IT professional since 2009..

Leave a Reply Cancel reply

Popular Posts

  • How to View or List Cron Jobs in Linux
  • How to Install PHP 8 on Ubuntu 20.04
  • How to Set Up SSH Tunnel with PuTTY
  • How to Install Tor Browser on Ubuntu 20.04
  • Issue with phpMyAdmin and PHP: Warning in ./libraries/sql.lib.php#613 count(): Parameter must be an array or an object that implements Countable”
  • How to Allow Remote Connections to MySQL
  • How to Install MySQL 8.0 on Ubuntu 20.04
  • How to Install Apache Kafka on Ubuntu 20.04
© 2013-2021 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy