Linux-Version-Image

Whether you’re troubleshooting an issue, installing new software, or just curious, knowing the exact version of your Linux operating system (OS) can be crucial. Thankfully, Linux offers several ways to quickly check your OS version. This blog post will guide you through the most common methods.

1. Using uname Command

The uname command is a powerful utility that provides detailed information about your system. To check the Linux kernel version and other system details, use the following command:

uname -a

This command outputs something like this:

Linux yourhostname 5.4.0-42-generic #46-Ubuntu SMP Fri Jul 10 00:24:02 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

Here’s a breakdown of the output:

  • Linux: Kernel name
  • yourhostname: Node name (your computer’s hostname)
  • 5.4.0-42-generic: Kernel version
  • #46-Ubuntu SMP Fri Jul 10 00:24:02 UTC 2020: Additional kernel build information
  • x86_64: Machine hardware name
  • GNU/Linux: Operating system

2. Using /etc/os-release File

The /etc/os-release file contains information about the operating system. To view its contents, use the cat command:

cat /etc/os-release

You’ll get an output similar to this:

NAME="Ubuntu"
VERSION="20.04.2 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.2 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 file provides comprehensive information about your OS, including the name, version, and various URLs for support and policies.

3. Using lsb_release Command

The lsb_release command is part of the Linux Standard Base (LSB) and provides distribution-specific information. To use it, type:

lsb_release -a

The output will be something like:

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.2 LTS
Release:        20.04
Codename:       focal

This command directly shows the distributor ID, description, release number, and codename, making it easy to identify your OS version.

4. Using hostnamectl Command

The hostnamectl command is primarily used to set the system hostname, but it also displays OS and kernel information. To check your OS version, use:

hostnamectl

You’ll see an output similar to:

   Static hostname: yourhostname
         Icon name: computer-vm
           Chassis: vm
        Machine ID: 1234567890abcdef1234567890abcdef
           Boot ID: 1234567890abcdef1234567890abcdef
    Virtualization: kvm
  Operating System: Ubuntu 20.04.2 LTS
            Kernel: Linux 5.4.0-42-generic
      Architecture: x86-64

This provides a clear overview of the system’s hostname, OS, kernel, and architecture.

Conclusion

Knowing how to check your Linux OS version is a handy skill for any Linux user. Whether you’re using uname, reading the /etc/os-release file, utilizing lsb_release, or hostnamectl, you can easily gather detailed information about your system. Each method provides different levels of detail, so you can choose the one that best suits your needs.

Next time you’re configuring your system or troubleshooting an issue, you’ll know exactly where to look to find out which Linux OS version you’re running. Happy Linux-ing!

How to Check Your Linux OS Version

Post navigation


Leave a Reply

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