- 4 Useful Commands to Check Linux Version
- What is the difference between Linux and other operating systems?
- What is the best Linux distribution?
- What are the benefits of using Linux?
- Check Linux version from /etc/os-release
- Check Linux version with uname command
- Check Linux version from /proc/version
- Check Linux version with lsb_release command
- What are some popular Linux distributions?
- What is the difference between Linux distributions?
- Why are there so many Linux distributions?
- How do I change my Linux distribution?
- How to Check OS Version from Command Line
- Checking the operating system version
- Final thoughts
- About the author
- Sidratul Muntaha
- How do I find out what version of Linux I’m running?
- 9 Answers 9
4 Useful Commands to Check Linux Version
How to check Linux version is a commonly asked question during a Linux job interview. The OS version of a Linux distribution can be determined by using the command-line interface as well as a graphical user interface.
In Linux, CLI is preferred over GUI as it provides more control over the OS. In this article, we will mostly focus on the command line methods which can be used to check the OS version of a Linux distribution.
What is the difference between Linux and other operating systems?
Linux is an open source operating system that was created in 1991 by Linus Torvalds. It is different from other operating systems because it is based on the Linux kernel. Linux is also free and can be used on a variety of devices.
What is the best Linux distribution?
The most popular and widely used distributions are Ubuntu, Debian, Red Hat Enterprise Linux (RHEL), CentOS, Fedora. Other distros include Arch Linux, Gentoo Linux and openSUSE.
What are the benefits of using Linux?
Some of the benefits of using Linux include its stability, security, flexibility and cost. Linux is also a more secure operating system than Windows. It can be used on a variety of devices, including desktops, laptops, servers and smartphones.
Check Linux version from /etc/os-release
The best way to check Linux version is using cat /etc/os-release command. This command will list Linux distribution name and release version information. It works on almost all Linux system.
If we are running a very old Linux distribution then we might not be able to use any of the above commands. Use the following command to know the OS version on our old system:
- ———- On Red Hat Linux ———-
$ cat /etc/redhat-release - ———- On CentOS Linux ———-
$ cat /etc/centos-release - ———- On Fedora Linux ———-
$ cat /etc/fedora-release - ———- On Debian Linux ———-
$ cat /etc/debian_version - ———- On Ubuntu and Linux Mint ———-
$ cat /etc/lsb-release - ———- On Gentoo Linux ———-
$ cat /etc/gentoo-release - ———- On SuSE Linux ———-
$ cat /etc/SuSE-release
Check Linux version with uname command
We can also use uname command to check Linux version. It is used to print our Linux system information such as kernel version and release name, network hostname, machine hardware name, processor architecture, hardware platform and the operating system.
The command uname -a shows the version of the Linux kernel we are using, as well as additional details.
Linux deb-srv 5.10.0-8-amd64 #1 SMP Debian 5.10.46-4 (2021-08-03) x86_64 GNU/Linux
Check Linux version from /proc/version
As we can see, the /proc/version file specifies the version of the Linux kernel, the version of gcc used to compile the kernel, and the time of kernel compilation. It also contains the kernel compiler’s user name.
Check Linux version with lsb_release command
The lsb_release command is a helpful utility to find out information about our Linux installation. It displays LSB (Linux Standard Base) information about the Linux distribution.
lsb_release -a
Output
Distributor ID: Debian
Description: Debian GNU/Linux 11 (bullseye)
Release: 11
Codename: bullseye
To display only the description, run:
What are some popular Linux distributions?
Ubuntu, Debian, Fedora, openSUSE, and Mint are all popular Linux distros.
What is the difference between Linux distributions?
There are many different types of Linux distributions, also called distros. Each one has its own features, but the core components are the same.
Why are there so many Linux distributions?
There are many reasons why there are so many Linux distributions. One reason is that Linux is open source, which means that anyone can create a new distribution. Linux is also very customizable, which means that people can create distributions that fit their needs or preferences. Additionally, different Linux distributions can appeal to different types of users. For example, some distributions are more geared towards beginners, while others are more geared towards experts.
How do I change my Linux distribution?
You can always switch to another distro if you find that it works better on your system or meets more of your needs. You will want to make sure that your system meets the requirements of the new distro, and you may need to reinstall some applications.
David is a Cloud & DevOps Enthusiast. He has years of experience as a Linux engineer. He had working experience in AMD, EMC. He likes Linux, Python, bash, and more. He is a technical blogger and a Software Engineer. He enjoys sharing his learning and contributing to open-source.
howtouselinux.com is dedicated to providing comprehensive information on using Linux.
We hope you find our site helpful and informative.
How to Check OS Version from Command Line
Linux is a powerful operating system that’s free and open-source. Because it’s open-source, Linux is available in numerous variations. Generally, each variant is known as a Linux distribution (also known as Linux distro). You may have already heard the name of the big ones like Ubuntu, Debian, RHEL, Fedora, Arch Linux, SUSE, etc.
Knowing the name and version of a distro is vital for users and administrators. The information is important in numerous situations like installing new apps or features, troubleshooting, etc. This guide will demonstrate how to check the OS version from the command line on Linux.
Checking the operating system version
Here are some of the simplest ways of checking the operating system version. Almost all of these methods should apply to any Linux distro. These methods utilize the built-in tools and feature Linux comes with.
Checking OS version from /etc/os-release
In Linux, the os-release file contains various information about the system. There are two copies of the file at two different locations.
Interestingly, the file located at /etc/os-release will take precedence over /usr/lib/os-release.
It contains information in the format of a newline-separated list of various variables. It contains info like OS name, version, version ID, builds ID, etc.
To check the content of the os-release file, run the following command.
Note that the output will vary from one Linux distro to another. This file will only be available if the OS uses the systemd as the init system.
Here are some examples that fine-tune the content of os-release to print only specific details. The following command will print only the version and name of the OS.
To check the version of the OS only, run the following command instead.
Checking OS version using lsb_release
The lsb_release tool provides certain LSB (Linux Standard Base) and distro-specific info. Generally, lsb_release is used in the following format.
Here, the flag “-a” tells lsb_release to print all the info about the OS it can provide. Alternatively, you can print a minimal report using the flag “-s” or “–short”. It will omit the headers in the output.
This tool also supports printing one specific piece of information at a time. For example, to print only the OS description, use the flag “-d” or “–description”.
To display the codename of the current OS, use the flag “-c” or “–codename”.
The man page contains an in-depth description of all the available options.
Checking OS version using hostnamectl
The hostnamectl command is responsible for managing the Linux system hostname and related settings. It can also print a host of info on the system and operating system.
Checking OS version using uname
Similar to lsb_release and hostnamectl, uname is another tool to report various info about the machine and operating system. However, the output is a bit more disorganized compared to hostnamectl output.
To print all the information about the system, run the following uname command. Here, the flag “-a” tells uname to print all the supported info.
We can also tell uname to print only specific detail. For example, the flag “-v” or “–kernel-version” will print the kernel version.
The following uname command will print the operating system label.
For all the available options and their explanations, check the man page.
Checking OS version from /etc/issue
The file /etc/issue stores system identification information. It’s generally shown before you’re prompted to log in to your account. Check the content of the file.
Checking OS version using /proc/version
It’s a text file that includes information about the Linux kernel.
Checking OS version using /etc/*release
If none of the aforementioned methods succeeded, then it’s highly likely that you’re running a very old Linux system. If that’s the case, then we have to take advantage of a very rudimentary method of checking OS information.
Run the following command.
Here, cat will read and print the content of all the files that match the pattern. You can check what files we’re reading from.
Final thoughts
This guide demonstrates how to check the version of the Linux operating system running on the machine. Although there are many third-party tools, we can achieve it using the built-in tools and features only.
The version of a Linux operating system is an important piece of information. Generally, Linux packages are built to work with a particular Linux version in mind. Knowing the Linux version can help in troubleshooting unexpected behaviors or errors. It’s also important when a new version of the Linux distro is released. It’s simple yet crucial info to keep track of.
About the author
Sidratul Muntaha
Student of CSE. I love Linux and playing with tech and gadgets. I use both Ubuntu and Linux Mint.
How do I find out what version of Linux I’m running?
Is there a way to determine what version (distribution & kernel version, I suppose) of Linux is running (from the command-line), that works on any Linux system?
I’d just like to point out for the record how stupid it is that this is a question which needs asking. This is really quite an indictment on the state of every linux distro.
9 Answers 9
The kernel is universally detected with uname :
$ uname -or 2.6.18-128.el5 GNU/Linux
There really isn’t a cross-distribution way to determine what distribution and version you’re on. There have been attempts to make this consistent, but ultimately it varies, unfortunately. LSB tools provide this information, but ironically aren’t installed by default everywhere. Example on an Ubuntu 9.04 system with the lsb-release package installed:
$ lsb_release -irc Distributor ID: Ubuntu Release: 9.04 Codename: jaunty
Otherwise, the closest widely-available method is checking /etc/something-release files. These exist on most of the common platforms, and on their derivatives (i.e., Red Hat and CentOS).
$ cat /etc/lsb-release DISTRIB_ID=Ubuntu DISTRIB_RELEASE=9.04 DISTRIB_CODENAME=jaunty DISTRIB_DESCRIPTION="Ubuntu 9.04"
But Debian has /etc/debian_version :
$ cat /etc/debian_version 5.0.2
Fedora, Red Hat and CentOS have:
Fedora: $ cat /etc/fedora-release Fedora release 10 (Cambridge) Red Hat/older CentOS: $ cat /etc/redhat-release CentOS release 5.3 (Final) newer CentOS: $ cat /etc/centos-release CentOS Linux release 7.1.1503 (Core)
$ cat /etc/gentoo-release Gentoo Base System release 1.12.11.1
I don’t have a SUSE system available at the moment, but I believe it is /etc/SuSE-release .
Slackware has /etc/slackware-release and/or /etc/slackware-version .
Mandriva has /etc/mandriva-release .
For most of the popular distributions then,
will most often work. Stripped down and barebones «server» installations might not have the ‘release’ package for the distribution installed.
Additionally, two 3rd party programs you can use to automatically get this information are Ohai and Facter.
Note that many distributions have this kind of information in /etc/issue or /etc/motd , but some security policies and best practices indicate that these files should contain access notification banners.