Knowing the Linux distribution name and version is essential for system administration. It helps in managing software installations and ensuring compatibility. Different distributions store this information in various locations, so multiple methods may be required to retrieve it.
Common ways to find this information include using commands like lsb_release and hostnamectl. You can also check system files such as /etc/os-release and /etc/issue. These methods will provide details about your Linux distribution name and version.
Understanding how to retrieve this information is crucial for maintaining and troubleshooting your system. The steps outlined below will guide you in obtaining the correct distribution name and version details.
Steps to check Linux distribution name and version:
- Open the terminal.
- Use lsb_release to check the distribution details.
$ lsb_release -a LSB Version: core-11.1.0ubuntu4-noarch:security-11.1.0ubuntu4-noarch Distributor ID: Ubuntu Description: Ubuntu 22.04.1 LTS Release: 22.04 Codename: jammy
Install lsb_core package if you get the No LSB modules are available warning.
$ sudo apt install lsb-core
- Examine the contents of the /etc/<distribution>-release file.
$ cat /etc/centos-release CentOS Linux release 8.3.2011
- Examine the contents of the /etc/system-release file.
$ cat /etc/system-release CentOS Linux release 8.3.2011
The file is normally just a symbolic link to /etc/<distribution>-release file.
$ ls -l /etc/system-release lrwxrwxrwx. 1 root root 14 Nov 10 10:49 /etc/system-release -> centos-release
- View additional details about your Linux distribution by examining the contents of the /etc/os-release file.
$ cat /etc/os-release NAME="CentOS Stream" VERSION="9" ID="centos" ID_LIKE="rhel fedora" VERSION_ID="9" PLATFORM_ID="platform:el9" PRETTY_NAME="CentOS Stream 9" ANSI_COLOR="0;31" LOGO="fedora-logo-icon" CPE_NAME="cpe:/o:centos:centos:9" HOME_URL="https://centos.org/" BUG_REPORT_URL="https://bugzilla.redhat.com/" REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux 9" REDHAT_SUPPORT_PRODUCT_VERSION="CentOS Stream"
- Examine the contents of the /etc/lsb-release file.
$ cat /etc/lsb-release DISTRIB_ID=Ubuntu DISTRIB_RELEASE=20.10 DISTRIB_CODENAME=groovy DISTRIB_DESCRIPTION="Ubuntu 20.10"
- Check the /etc/issue file for basic information.
$ cat /etc/issue Ubuntu 20.04.2 LTS \n \l
- Retrieve OS and distribution information using the hostnamectl command.
$ hostnamectl Static hostname: host Icon name: computer-vm Chassis: vm Machine ID: 421dd0de69664dc49728efbdd7ef476d Boot ID: a881d479f0364cb387a972597dce5ee4 Virtualization: parallels Operating System: CentOS Stream 9 CPE OS Name: cpe:/o:centos:centos:9 Kernel: Linux 5.14.0-165.el9.aarch64 Architecture: arm64 Hardware Vendor: Parallels International GmbH. Hardware Model: Parallels ARM Virtual Machine
- Use the uname command to see kernel version and architecture.
$ uname -a Linux host 5.8.0-34-generic #37-Ubuntu SMP Thu Dec 10 18:01:14 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
Some information can be inferred, such as the kernel version 5.8 indicating that the system is running Ubuntu 20.10.
Mohd Shakir Zakaria is an experienced cloud architect with a strong development and open-source advocacy background. He boasts multiple certifications in AWS, Red Hat, VMware, ITIL, and Linux, underscoring his expertise in cloud architecture and system administration.
Comment anonymously. Login not required.