Posted on March 21, 2023 by nexonhost
How To Check Linux Version.
This article shows how to check what Linux distribution and version is installed on your system using the command line.
Some of the most popular Linux distributions are Debian, Red Hat, Ubuntu, Arch Linux, Fedora, CentOS, Kali Linux, OpenSUSE, Linux Mint, etc.
A Linux distribution is an operating system made from a Linux kernel, GNU tools and libraries, and software collections. Usually, Linux distributions include desktop environments, package management system, and a set of preinstalled applications.
lsb_release command
The lsb_release utility displays LSB (Linux Standard Base) information about the Linux distribution. This command should work on all Linux distributions that have the lsb-release package installed:
lsb_release -a
No LSB modules are available. Distributor ID: Debian Description: Debian GNU/Linux 9.5 (stretch) Release: 9.5 Codename: stretch
The Linux distribution and version are shown in the Description line. As you can see from the output above, I have Debian GNU/Linux 9.5 (stretch) installed on my system.
Instead of printing all of the above information, you can display the description line, which shows your Debian version passing the -d switch.
lsb_release -d
The output should look similar to below:
Description: Debian GNU/Linux 9.5 (stretch)
If you get “command not found: lsb_release” you can try to identify the Linux version using some of the other methods below.
/etc/os-release file
The /etc/os-release file contains operating system identification data, including information about the distribution. This file is part of the systemd package and should be present on all system running systemd.
To view the contents of the os-release file, use either cat or less :
cat /etc/os-release
The output should look something like below:
PRETTY_NAME="Debian GNU/Linux 9 (stretch)" NAME="Debian GNU/Linux" VERSION_ID="9" VERSION="9 (stretch)" ID=debian HOME_URL="https://www.debian.org/" SUPPORT_URL="https://www.debian.org/support" BUG_REPORT_URL="https://bugs.debian.org/"
/etc/issue file
The /etc/issue file contains a system identification text that is printed before the login prompt. Usually, this file includes information about the Linux version:
cat /etc/issue
The output will look something like this:
Debian GNU/Linux 9 \n \l
hostnamectl command
hostnamectl utility is part of systemd and is used to query and change the system hostname. This command also displays the Linux distribution and kernel version .
hostnamectl
Static hostname: debian9.localdomain Icon name: computer-vm Chassis: vm Machine ID: a92099e30f704d559adb18ebc12ddac4 Boot ID: 7607cbe605d44f638d6542d4c7b3878e Virtualization: qemu Operating System: Debian GNU/Linux 9 (stretch) Kernel: Linux 4.9.0-8-amd64 Architecture: x86-64
/etc/*release file
If none of the commands above work for you, then most likely, you are running a very old and outdated Linux distribution. In this case, you can use one of the following commands, which should print the content of the distribution release or version file:
cat /etc/*release
cat /etc/*version
You can find more information about the release/version files at this link .
uname command
The uname command displays several system information, including the Linux kernel architecture, name, version, and release.
To find out what version of the Linux kernel is running on your system, type the following command:
uname -srm
Linux 4.9.0-8-amd64 x86_64
The output above tells us that the Linux kernel is 64-bit, and its version is “4.9.0-8-amd64”.
Conclusion
There are several different commands that can help you find out the Linux distribution and version is running on the system.
Comments are closed.
1 Comment
How to use the date command in Linux - Nexonhost.com (May 4, 2023)
[…] the Linux date […]