- How do I find out what version of Linux I’m running?
- 9 Answers 9
- How to Check OS Version from Command Line
- Checking the operating system version
- Final thoughts
- About the author
- Sidratul Muntaha
- How to Check the Linux OS Version (6 Ways)
- 1. Check Linux Version using lsb_release Command
- 2. Check Linux OS Version using Neofetch
- 3. Check Linux Version using Cat Command
- 4. Check Linux Version using Uname Command
- 5. Check Linux Version using Hostnamectl Command
- 6. GUI Method to Check the Linux OS Version
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.
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 to Check the Linux OS Version (6 Ways)
Linux OSes are some of the best replacements for Windows and macOS because they have gotten impressively capable over the years. Not just the Linux kernel but a lot of components like desktop environments and display servers are now more capable than they were before. With too many distro releases, keeping track of Linux versions could be challenging, especially on rolling releases. So, here are six ways to check the Linux OS version easily on your PC.
1. Check Linux Version using lsb_release Command
“LSB” stands for Linux Standard Base and the lsb_release command was specially developed to allow Linux users to check their Linux OS version; that’s all it does. To check the Linux OS version, paste the below command in the terminal and hit enter.
The -a stands for “all” in the command, meaning you are asking the “lsb_release” command to list all the details about your Linux distro. You could also use -d, -r, and -c to find out the description, release, and codename using this command, respectively.
2. Check Linux OS Version using Neofetch
Unlike other commands that only display text, Neofetch is a fancy command that displays the ASCII art of the logo of the distro you are using. In addition to the artwork, it shows everything you would need to know about the distro, including the Linux version, resolution, desktop environment, processor, GPU, and memory. Now, the Neofetch command doesn’t come installed by default, so you will first need to install it.
# For Ubuntu/Debian-based distros sudo apt install neofetch # For Fedora/CentOS sudo dnf install neofetch # For Arch-based distros sudo pacman -S neofetch # For OpenSUSE sudo zypper install neofetch
Once installed, type neofetch in the Linux command line and hit Enter. Here’s what you will see as the output:
3. Check Linux Version using Cat Command
The cat command in Linux stands for “concatenate,” and this highly useful Linux command is specifically used to display file contents in the terminal. To get the details about the Linux OS version using the cat command, we need to target the “os-release” text file that resides in the /etc directory inside the root. Here’s how:
4. Check Linux Version using Uname Command
Most of the aforementioned commands do not display the kernel version. However, if you specifically want to check the kernel version of your Linux OS, uname is the only command you need.
“uname” is short for Unix Name and is specifically meant to display details about Linux desktops. It comes built into Linux, and here is how you use the command:
5. Check Linux Version using Hostnamectl Command
Last but not least command, you can also use the “Hostnamectl” command to find out the Linux OS version. As the name suggests, this command is used to display the hostname of the distro. This command will only work with sudo privileges:
6. GUI Method to Check the Linux OS Version
If you are new to Linux, you probably don’t like the terminal much because it hasn’t grown on you yet. Hence, if you don’t like using the terminal and are looking for a way to find out the Linux version, it’s possible with this GUI method.
1. Go to Settings on your Linux PC.
2. Scroll all the way down and open the “About” section.
3. Here, you should see the details about the installed Linux distro.
Bear in mind that the Settings app on your distro may look vastly different from ours. If you don’t see the “About” section right away, it’s usually located in the settings and you may need to dig a bit deeper.
Frequently Asked Questions
There are different commands like lsb_release, uname, Hostnamectl, cat, and neofetch that you can use to check the current version on Linux OS.
To check the Linux version on Ubuntu, go to the command terminal and execute the “lsb_release” command.