When we talk about Linux, we usually mean some kind of Linux distribution. Also by Linux we can mean the Linux kernel.
Sometimes you need to determine the version of Linux you are running. The user may not know or forget which version of the distribution or which version of the Linux kernel is being used. If this is a foreign system, you may need to find out the name of the distribution used.
This article discusses various methods that will help us determine the version of Linux we are using. Several commands are covered to determine the Linux version. The given commands are universal and do not depend on the distribution. It is possible that some of them may not work on some distributions, in which case move on to the next command and try it.
lsb_release command
The lsb_release command displays information about the distribution.
Prefix lsb
in the team name refers to the Linux Standard Base project, which was created with the goal of creating a set of standards for releasing Linux distributions in order to reduce the differences between individual distributions. The use of LSB is expected to reduce the costs associated with porting applications across different distributions, as well as the effort associated with maintaining those applications.
To display information about the distribution, run the command:
lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 18.10 Release: 18.10 Codename: cosmic
The distribution name, version number and code name are displayed.
You can use the -d option to show only the Description
, which usually contains both the name and version of the distribution.
lsb_release -d Description: Ubuntu 18.10
How to find out if Linux is 32 or 64 bit?
uname -m
Result of executing the commands:
$ cat /etc/issue Debian GNU/Linux 7 nl
$ lsb_release -a No LSB modules are available. Distributor ID: Debian Description: Debian GNU/Linux 7.3 (wheezy) Release: 7.3 Codename: wheezy
$ uname -m x86_64
As a result, we get Debian 7.3 64bit wheezy. Now you know how to view the Linux version. As you can see, there are quite a few ways to solve this problem in Linux. I hope this information was healthy for you.
hostnamectl command
The hostnamectl command, executed without parameters or with the status key, displays current information about the system.
hostnamectl Static hostname: p Icon name: computer-desktop Chassis: desktop Machine ID: abc231434aabcb…a Boot ID: 51dcaa2321bbbb…a Operating System: Ubuntu 18.10 Kernel: Linux 4.18.0-16-generic Architecture: x86-64
In addition to the distribution data, the kernel version and architecture are displayed.
Find out the Linux version
Linux is just a kernel on which various distributions are developed. Sometimes it’s easy to get confused in their abundance, but knowing how to check the version of the kernel itself or the graphical shell, you can find out all the necessary information at any time. And there are many ways to check.
Method 1: Inxi
Inxi will help you collect all the information about the system in no time, but it is pre-installed only in Linux Mint. But it doesn’t matter, absolutely any user can install it from the official repository in a few seconds.
Installation of the utility and work with it will take place in the “Terminal” - an analogue of the “Command Line” in Windows. Therefore, before starting to list all the possible variations of checking information about the system using the “Terminal”, it is worth making a note and telling how to open this very “Terminal”. To do this, you need to press the key combination CTRL + ALT + T or search the system with the search query “Terminal” (without quotes).
uname command - kernel version
The uname command displays information about the current Linux kernel, as well as some additional information.
To display all information, use the -a switch
uname -a Linux p 4.18.0-16-generic #17-Ubuntu SMP Fri Feb 8 00:06:57 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
For convenience, you can only display the kernel name (-s), kernel version (-r) and architecture (-m)
uname -srm Linux 4.18.0-16-generic x86_64
Operating system, hostname and Linux kernel
The -o or --operating-system option displays the operating system being used:
uname -o
The -n or --nodename option displays the hostname:
uname -n
To find a Linux kernel release, use the -r or --kernel-release option:
uname -r
The -v or --kernel-version option displays the kernel version:
uname -v
If you need all of the above information in one command, use the -a or --all option as follows:
uname -a
Finally, to find out the version of the uname utility, use the --version command:
uname --version
File /etc/os-release
/etc/os-release file contains information about the distribution, including system website URLs and some additional data. This file is present in distributions that use systemd.
To display the contents of the /etc/os-release file, you can use the cat
:
cat /etc/os-release NAME=»Ubuntu» VERSION=»18.10 (Cosmic Cuttlefish)» ID=ubuntu ID_LIKE=debian PRETTY_NAME=»Ubuntu 18.10″ VERSION_ID=»18.10″ 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=cosmic UBUNTU_CODENAME=cosmic
Finding out the Linux version through the terminal
There are many ways to find out the Linux version, from basic signs to opening a file and viewing the distribution and OS version. Only the most popular methods will be considered.
For most distributions, the lsb-release command with the -a arguments will do.
lsb_release -a
As you can see in the screenshot above, I have Debian 7.8.
The second method includes viewing the “*-release” file.
Command in terminal:
cat /etc/*-release
If you are using Ubuntu, then this command will output information from 2 files: /etc/lsb-release and /etc/os-release.
Using them you can fully find out the data about the distribution. However, when running the same command in ArchLinux, the result will be completely different.
The third method is to view data on the build of Debian packages.
dpkg -l openssl
If you have an RPM system, then the path is different:
rpm -qa | grep openssl
Files /etc/***release and /etc/***version
If you are using an older or specific Linux distribution, then system information may be stored in the /etc/ abc
-release or /etc/
abc
-version.
Instead of abc
Usually the short distribution identifier or
lsb
if the system is compatible with LSB standards. Instead of a symbol, there may be a _ symbol. For example, the Fedora distribution uses the file /etc/fedora-release
It is not necessary to know the names of these files. You can use the following command to automatically determine the names and display the contents of these files:
echo /etc/*_ver* /etc/*-rel*; cat /etc/*_ver* /etc/*-rel* /etc/debian_version /etc/lsb-release /etc/os-release buster/sid DISTRIB_ID=Ubuntu DISTRIB_RELEASE=18.10 DISTRIB_CODENAME=cosmic DISTRIB_DESCRIPTION=»Ubuntu 18.10″ NAME= "Ubuntu" VERSION="18.10 (Cosmic Cuttlefish)" ID=ubuntu ID_LIKE=debian PRETTY_NAME="Ubuntu 18.10″ VERSION_ID="18.10″ 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= cosmic UBUNTU_CODENAME=cosmic
How to find out the Linux version?
In fact, there are many methods for this, ranging from general signs to opening the file and exactly looking at the version and distribution name. Let's consider only the most popular of them.
Find out the distribution
First of all, let's find out the name of the distribution and its version if possible. To do this, we will look at the contents of the files in the /etc/ folder that end with release:
cat /etc/*-release
On Ubuntu, the utility will output the contents of two files /etc/lsb-release and /etc/os-release. They will contain comprehensive information about the name of the distribution and its release version:
But if we run the same command in ArchLinux, we get a completely different result:
There is no longer a version, there is only a distribution name, since ArchLinux uses a rolling release system. A little less, but almost all the same information can be obtained using the lsb_release command:
lsb_release -a
Also, very often you can find out the name of the distribution by looking at the “About” for any system application or, better yet, the “Settings” :
And another way to see the distribution version on Debian-based systems is to look at the package's build information:
dpkg -l openssl
Or for RPM systems:
rpm -qa | grep openssl
Find out the kernel version
In many cases, we need not so much the version of the Linux distribution, but the version of the kernel that it uses. There are also several commands to view this information:
uname -a
Or:
uname -r
I am using kernel version 4.8.0-59, here we see the system architecture - x86_64. The SMB designation means that the kernel supports multi-core processors or multiple processors. But we can find out the same information by looking at the contents of the /proc/version file:
cat /proc/version
You can also look at the kernel launch parameters line, it also contains the version:
cat /proc/cmdline
There are several more files with similar information:
cat /proc/sys/kernel/{ostype,osrelease,version}
How to find out computer architecture
You already know how to find out the Linux version, distribution name and kernel, the architecture has already been mentioned in the commands above, but there is a separate command that displays only the architecture:
arch
You can use uname for the same purposes:
uname -m
Determining the Ubuntu version from the command line
lsb_release command
The lsb_release command is designed to display information about the current version of the Ubuntu distribution. To obtain the required information, run lsb_release -a at the command line:
$ lsb_release -a Distributor ID: Ubuntu Description: Ubuntu 9.10 Release: 9.10 Codename: karmic
As you can see, we received a version (Release) and a codename (Codename).
File /etc/lsb-release
Also, information about the Ubuntu version is stored in the /etc/lsb-release file. To output the file, run cat /etc/lsb-release at the command prompt:
$ cat /etc/lsb-release DISTRIB_ID=Ubuntu DISTRIB_RELEASE=9.10 DISTRIB_CODENAME=karmic DISTRIB_DESCRIPTION=”Ubuntu 9.10″
File /etc/issue
Another easy way to determine the version is to look at the contents of the /etc/issue file, although the file itself serves a slightly different purpose. To do this, on the command line run:
$ cat /etc/issue Ubuntu 9.10 \n \l
Determine the current kernel version
Above I wrote how you can determine the Ubuntu kernel version using System Monitor. You can also use the uname command to determine the kernel version. Run on the command line:
$ uname -r 2.6.31-20-generic
The -r option is used to display information about the kernel version. You can also display all the information provided by the uname command by running the command with the -a option.
If you were brought to this article by an irrepressible desire to find out “how to find out the Linux version,” that is, the basics of the Linux world, then I even envy you a little. This means that you are now at the very beginning of your journey of learning the magic of Linux and you have everything ahead of you. I would love to trade places with you now. Teach me to “remember” all this