Check Linux operating system distribution version

The generally correct way to check Linux operating system version is via /etc/os-release:

cat /etc/os-release

Operating system specific

On very old Linux distributions such as CentOS 6, /etc/os-release may not exist. Scripts should check /etc/os-release first, and if it doesn’t exist, go to specific files if needed.

  • CentOS / RHEL: /etc/redhat-release
  • Debian / Ubuntu: /etc/debian_version