The Quick Answer: os-release
cat /etc/os-release
Every current distribution has this file. A shortened example from Ubuntu 24.04 (your point release may differ):
PRETTY_NAME="Ubuntu 24.04.3 LTS"
NAME="Ubuntu"
VERSION_ID="24.04"
VERSION_CODENAME=noble
ID=ubuntu
ID_LIKE=debian
| Field | Meaning |
|---|---|
PRETTY_NAME | Full name for people |
ID | Short name for scripts |
VERSION_ID | Release number |
ID_LIKE | Family it belongs to |
Debian and Ubuntu also set a code name such as noble. A script can load the file and use the fields directly:
. /etc/os-release && echo "$ID $VERSION_ID"
lsb_release
lsb_release -a
It prints the distributor, a description, the release number, and the code name. The command comes from a separate package that minimal installs often leave out: on Debian and Ubuntu, add it with sudo apt install lsb-release. On AlmaLinux and Rocky Linux it is not part of a default install, so rely on os-release there.
hostnamectl
hostnamectl
On any system with systemd, hostnamectl shows the operating system, the kernel, and the architecture in one block, together with the host name and, on a virtual server, the type of virtualization. It takes the operating system name from the same os-release file, so the two always agree.
Files of Single Distributions
| File | Found on |
|---|---|
/etc/debian_version | Debian, Ubuntu |
/etc/redhat-release | AlmaLinux, Rocky |
/etc/almalinux-release | AlmaLinux |
/etc/rocky-release | Rocky Linux |
On Debian, /etc/debian_version holds the point release. On Ubuntu the same file names the Debian development branch it was built from, not the Ubuntu release, so do not use it to identify Ubuntu.
The Kernel Version: uname -r
uname -r
uname -a
The first command prints only the kernel release, such as a 6.8 kernel with a build suffix on Ubuntu 24.04 with its original kernel (newer with a hardware enablement kernel), a 5.14 kernel with an el9 suffix on AlmaLinux and Rocky Linux 9, or a 6.12 kernel with an el10 suffix on version 10. The number before the first dash is the upstream kernel version; the rest is the distribution's own build. uname -a adds the host name, build date, and architecture. Kernel updates and the difference between running and installed kernels are covered in how to check the kernel version in Linux, and the kernel's role in what is a kernel.
The Architecture: uname -m
uname -m
x86_64 means a 64-bit Intel or AMD processor, and aarch64 a 64-bit ARM processor. On Debian and Ubuntu, dpkg --print-architecture gives the package names of the same thing, amd64 or arm64, which is what download pages ask for. See x64 vs x86.
Distribution or Kernel: Which Do You Need?
- Installing software: follow the distribution and release, because repositories and packages are built per release.
- Support period: also follows the release, not the kernel.
- Drivers and kernel features: follow the kernel version.
- Inside a container: os-release shows the image's distribution, while
uname -rshows the host's kernel, because containers share it. - Asking for help: give both, the output of
cat /etc/os-releaseand ofuname -r, so others can match your packages and your kernel.
Commands at a Glance
| Command | Shows |
|---|---|
cat /etc/os-release | Distribution, release |
lsb_release -a | Same, if installed |
hostnamectl | OS, kernel, architecture |
uname -r | Kernel version |
uname -m | Architecture |
For steps specific to one family, see how to check the Ubuntu version and how to check the RHEL version.