Linux is an open-source operating system that has been widely used for decades. It comes in various distributions or flavors, each with its unique features and characteristics. As a Linux user, one of the essential tasks you need to perform is to check the version of the distribution you are running. Knowing the version number is crucial when troubleshooting issues, updating software, or installing new packages. In this article, we will discuss how to check Linux version using different methods.
Method 1: Using the Terminal
The terminal is a command-line interface that allows you to interact with Linux. You can use it to execute different commands, including the one for checking the Linux version. Here’s how to do it:
- Open the terminal by pressing
Ctrl+Alt+T
on your keyboard. - Type the following command and hit enter:
lsb_release -a
- The output will display detailed information about your Linux distribution, including the version number, codename, and release date.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.2 LTS
Release: 20.04
Codename: focal
Alternatively, you can use the following command to get only the version number:
lsb_release -r
The output will show only the release version:
Release: 20.04
Method 2: Using the /etc/os-release File
Another way to check the Linux version is by examining the /etc/os-release
file. This file contains information about the Linux distribution, including the version number, ID, and name. Here’s how to do it:
- Open the terminal.
- Type the following command and hit enter:
cat /etc/os-release
- The output will display detailed information about your Linux distribution, including the version number, ID, and name.
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
Method 3: Using the /proc/version File
The /proc/version
file contains information about the Linux kernel version and build date. It can also be used to check the Linux version. Here’s how to do it:
- Open the terminal.
- Type the following command and hit enter:
cat /proc/version
- The output will display information about the Linux kernel version and build date.
Linux version 5.4.0-80-generic (buildd@lgw01-amd64-051) (gcc version 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04)) #90-Ubuntu SMP Fri Jul 9 22:49:44 UTC 2021
Method 4: Using the hostnamectl Command
The hostnamectl
command is used to set or display the hostname of the Linux system. It can also be used to check the Linux version. Here’s how to do it:
- Open the terminal.
- Type the following command and hit enter:
hostnamectl
- The output will display detailed information about your Linux distribution, including the version number, ID, and name.
Static hostname: ubuntu
Icon name: computer-vm
Chassis: vm
Machine ID: 2d3a3f8a7c5e4d1b9c5a9cb5b5f5e5f5
Boot ID: a8f7b1a0c0ef4d9e9c2d2e0c2d2e0c2d
Virtualization: kvm
Operating System: Ubuntu 20.04.2 LTS
Kernel: Linux 5.4.0-80-generic
Architecture: x86-64
Conclusion
In this article, we discussed how to check Linux version using four different methods. The terminal, /etc/os-release
file, /proc/version
file, and hostnamectl
command can all be used to obtain information about the Linux distribution version. Knowing the version number is crucial when troubleshooting issues, updating software, or installing new packages. By using these methods, you can easily determine the Linux version you are running and continue working with your system seamlessly.