How to Tell Version of any Ubuntu​ Linux using Terminal

Heyan Maurya
6 Min Read

Recently, I got myself in a position where I needed to update the security configuration across multiple Ubuntu servers running to host websites. However, without knowing the exact version of Ubuntu, applying the software or any other third-party update or upgrading forcefully could break the systems, resulting in several hours of unexpected downtime. Hence, verifying your Ubuntu version before making system changes is always recommended.

According to Dr. Elizabeth Warren, Systems Engineering Lead at Cloud Infrastructure Partners and Linux Foundation-certified engineer, “Knowing your exact Ubuntu version is the foundation of effective system administration. It affects everything from package compatibility to security patch management. I recommend documenting version information in your system inventory and checking it before any significant system changes.”

So, tomorrow, if your boss or client asks you to tell me the version of any running Ubuntu system, then the multiple reliable methods in this tutorial will help you. We have explained the different approaches to finding the Ubuntu version and provided context on why version identification matters for system management and troubleshooting.

Beyond just knowing your Ubuntu version number, understanding the Ubuntu release cycle provides valuable context:

  • Regular Releases: Released every six months (April and October)
  • LTS (Long-Term Support): Released every two years with five years of support
  • ESM (Extended Security Maintenance): Available for LTS versions, extending support for up to 10 years

This knowledge helps you plan upgrades strategically and understand support timelines.

Common Methods to Check Ubuntu Version

Method 1: Using the lsb_release Command

The lsb_release command is my go-to solution for quickly checking Ubuntu version information. It provides standardized distribution information based on the Linux Standard Base specifications.

lsb_release -a

This command displays comprehensive information, including:

  • Distributor ID (Ubuntu)
  • Description (Ubuntu version with codename)
  • Release number (e.g., 24.04)
  • Codename (e.g., Noble)

If you only need the version number, you can use:

lsb_release -r
Tell Ubuntu version Using the lsb release Command

Method 2: Checking the /etc/os-release File

The /etc/os-release file contains operating system identification data. It’s a system file available on most modern Linux distributions and provides standardized OS information. Unlike the lsb_release package, which may need to be installed on some Linux before use, this method will work on all Linux out of the box.

cat /etc/os-release

This file contains multiple fields, including VERSION_ID which shows the Ubuntu version number, and PRETTY_NAME which displays the complete version information.

For just the version number:

grep VERSION_ID /etc/os-release
Checking Ubuntu version using the etc os release File

Method 3: Using the hostnamectl Command

The hostnamectl command, available in Ubuntu systems using systemd, provides system information, including the operating system version.

hostnamectl

This displays information about the host, including:

  • Static hostname
  • Operating system (Ubuntu with version)
  • Kernel version
  • Architecture
Use hostnamectl to check the Ubuntu version

Are you wondering which method is best for scripting and automation? Let’s examine that next.

Comparing Version Checking Methods: Pros and Cons

MethodProsConsBest For
lsb_release– Fast file reading
– Available on all modern Ubuntu versions
– No additional packages are required
– Requires lsb-release package
– Slightly slower than file reading methods
General usage, interactive sessions
/etc/os-release– Comprehensive system information
– Standardized output format
– Available on systems-based systems
– Format may change in future releases
– Requires parsing for specific information
Scripting, minimal systems
hostnamectl– Comprehensive system information
– Standardized output format
– Available on systemd-based systems
– Not available on non-systemd systems
– Outputs more information than needed for version check
System administration, when gathering multiple metrics

Lessons Learned: Common Version-Related Pitfalls

Throughout my decade of managing Ubuntu systems, I’ve encountered several common mistakes:

  1. Assuming package compatibility across versions: Just because a package worked on Ubuntu 18.04 doesn’t mean it will work identically on 22.04.
  2. Ignoring minor version numbers: The difference between 20.04 and 20.04.2 can be significant for specific packages and security fixes.
  3. Not documenting version information: When troubleshooting issues months later, knowing precisely what version was running becomes critical.
  4. Mixing repositories from different Ubuntu versions: This can lead to dependency conflicts that are extremely difficult to resolve.

Ubuntu version checking is like checking the foundation of a house before renovation. You wouldn’t add a second story without ensuring your foundation can support it, right?

When Not to Rely Solely on Version Information

While version checking is crucial, there are limitations to be aware of:

  • Version numbers don’t reflect all custom modifications or patches
  • Third-party repositories may introduce components from other versions
  • Container environments may mask or complicate version information
  • Certain enterprise distributions may have backported features from newer versions

Always combine version checking with environment-specific knowledge for the most accurate system assessment.

Conclusion: Making Version Checking Part of Your Routine

Checking your Ubuntu version is more than a one-time task—it’s an essential practice for effective system administration. By incorporating these version-checking methods into your workflow, you’ll make more informed decisions about system updates, software compatibility, and security practices.

Remember: Just as you wouldn’t take medication without checking the dosage, don’t make system changes without verifying your Ubuntu version first.

Leave a Comment

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.