cat /etc/os-release
SafeIdentify the distro
cat /etc/os-release
The reliable way to identify distro and version — decides apt-vs-dnf paths and support status.
Examples
cat /etc/os-release | grep PRETTYOne-line OS namegrep -E '^(ID|ID_LIKE|VERSION_ID)=' /etc/os-releaseShow only the family and version number (for branching in runbooks). /etc/os-release && echo "$ID $VERSION_ID"Load the values as shell variableshostnamectlOS name, kernel and virtualisation type in one view (systemd hosts)uname -rKernel version only
Syntax
cat /etc/os-release / lsb_release -a
Key points
- /etc/os-release exists on practically every current distribution: RHEL 7 and later, Ubuntu, Debian, SUSE and more.
- ID_LIKE tells you the family: rhel or fedora means dnf/yum, debian means apt.
- Inside a container it reports the container image's OS, not the host's.
When it does not work
- If the file is missing, the host is old (CentOS 6 and similar). Check /etc/redhat-release or /etc/issue instead.
- lsb_release: command not found means the package (redhat-lsb-core or lsb-release) is not installed. cat /etc/os-release gives the same answer.
Before you run it
Read only.
Related commands
- unameKernel/OS info
- hostnamectlShow/set hostname
The same reference, with no signal at all
Every command on this site, held on your device. The app adds 632 more: 1,510 commands and 120 fix flows, searchable with no connection. Free to install, no ads (some content is a one-time purchase).
Get it free on the App Store