The cat /etc/os-release
command is the most common method to see which distribution and version a Linux system has. This file contains basic information such as the operating system's name, version, ID, and code name.
Command:
cat /etc/os-release
Sample Output (for AlmaLinux 8):
NAME="AlmaLinux"
VERSION="8.9 (Midnight)"
ID="almalinux"
ID_LIKE="rhel centos fedora"
VERSION_ID="8.9"
PLATFORM_ID="platform:el8"
PRETTY_NAME="AlmaLinux 8.9 (Midnight)"
ANSI_COLOR="0;34"
CPE_NAME="cpe:/o:almalinux:almalinux:8::baseos"
HOME_URL="https://almalinux.org/"
BUG_REPORT_URL="https://bugs.almalinux.org/"
Explanations:
-
NAME
: The name of the distribution (e.g., Ubuntu, AlmaLinux, Debian) -
VERSION
: Human-readable version information -
ID
: The system ID of the distribution -
VERSION_ID
: The exact version number (e.g., 8.9) -
PRETTY_NAME
: The full system name for display purposes
Alternative Commands:
-
To see only the distribution name and version:
grep -E '^NAME=|^VERSION=' /etc/os-release
-
For a cleaner look:
awk -F= '/^NAME=|^VERSION=/{gsub(/"/,""); print $2}' /etc/os-release
-
System information can also be obtained with
hostnamectl
:
hostnamectl
This command also lists kernel and architecture information along with the operating system.
When to Use?
-
To verify which Linux distribution is being used
-
To perform distribution-specific operations in system scripts
-
When specifying the system version in support or update processes
/etc/os-release
is a standard recognized by the Linux Foundation and is found in almost all modern distributions.