When most people talk of Linux, they are always referring to a Linux distribution. However, this is not the case. Linux itself is a kernel which acts as a bridge between user applications and the hardware. When we talk of a Linux distribution, we refer to an operating system developed from the Linux kernel. A distribution comes with a package manager, pre-installed applications, a Desktop Environment, and several more features.
Some of the popular Linux distributions include; Ubuntu, Fedora, Manjaro, CentOS, Kali Linux, Linux Mint, and more. In this post, I will use a Linux distribution called Parrot. It is one of the many penetration testing distros available. Others include Kali Linux, Backbox, etc.
Knowing the Linux version running on your machine will help you a great deal. For example, understanding which Linux distribution you are using will determine how you install your applications and packages. That is because every Linux distribution comes with its package management system.
In this post, you will learn how to check your Linux distribution, its version, and the kernel using the command-line.
Check the Linux Version
There are several terminal commands that you can execute to know your Linux version and distribution.
1. The “lsb_release” command
The lsb_release is a utility that provides Linux Standard Base (LSB) information about the distribution you are using. This command should work on all Linux distribution, which has the lsb_release package installed.
Execute the command below in the Terminal.
lsb_release -a
From the output shown in the image above, the ‘Description’ value shows I am currently running Parrot GNU/Linux 4.7.
If you wanted only to display this description information, including the ‘-d’ parameter instead of ‘-a.’ See the command below.
lsb_release -d
To list other arguments you can use with the “lsb_release” utility, use the ‘–help’ option as shown below.
lsb_release --help
If you get an error like “command not found: lsb_release” don’t worry, there are still other commands we can use to determine your Linux version.
2. Display “/etc/os-release” file contents
Another method you can use to know your Linux distribution and version is checking the contents of the ‘os-release‘ file in the ‘/etc. ‘ directory. You can use the ‘cat’ or ‘less’ command to display the contents.
cat /etc/os-release less /etc/os-release
3. Display “/etc/issue‘ file contents
Another way is displaying the contents of the ‘issue‘ file in the ‘/etc.’ directory. It holds the system identification text displayed before login. Run the command below.
cat /etc/issue
4. The “hostnamectl” command
Another powerful utility we can use is ‘hostnamectl.’ It displays information about the Linux distribution, version, kernel, and more. You can also use it to change the hostname.
hostnamectl
5. The “uname” command
The uname command shows information like the kernel architecture, version, name, and release. Execute the command below.
uname -srm
Additional Commands…
If the above commands don’t work for, you will probably run an old or outdated Linux distribution. However, this doesn’t mean its dead end for you. Try any of the commands below;
cat /etc/*release cat /etc/*version
Conclusion
Those are four ways you can use to check your Linux version. My favorite method is using the “hostnamectl” command. I find it more comfortable and convenient. What about you? Feel free to tell us below.