Checking the exact Linux distribution and release keeps repository instructions, package choices, and support decisions aligned with the system that is actually running. A path or package name that fits Ubuntu 24.04 can be wrong on Debian 12, Fedora, or a rolling-release host.

Current Linux distributions publish their identity through the standard os-release metadata file. /etc/os-release is the preferred path for applications and usually points to the vendor copy under /usr/lib/os-release, with fields such as PRETTY_NAME, ID, VERSION_ID, VERSION, VERSION_CODENAME, and ID_LIKE describing the distribution rather than the running kernel.

Minimal containers and stripped images often omit helper commands such as lsb_release or hostnamectl, but os-release remains the common source that package documentation and support tooling expect. Some distributions leave optional fields such as VERSION_ID, VERSION_CODENAME, or ID_LIKE unset, so rely only on the keys that are actually present on the host.

Steps to check Linux distribution name and version:

  1. Print the main distribution name and release fields from os-release.
    $ grep -E '^(PRETTY_NAME|NAME|VERSION_ID|ID|ID_LIKE)=' /etc/os-release
    PRETTY_NAME="Ubuntu 24.04.4 LTS"
    NAME="Ubuntu"
    VERSION_ID="24.04"
    ID=ubuntu
    ID_LIKE=debian

    PRETTY_NAME is the human-readable label, while ID and VERSION_ID are the machine-friendly values commonly used in repository instructions, scripts, and support matrices.

  2. Read the version string and codename when a support case, repository guide, or release note refers to the named release instead of the numeric version.
    $ grep -E '^(VERSION|VERSION_CODENAME)=' /etc/os-release
    VERSION="24.04.4 LTS (Noble Numbat)"
    VERSION_CODENAME=noble

    VERSION is presentation text and can include the release name, while VERSION_CODENAME is an optional short identifier such as noble or bookworm.

  3. Read the full metadata file when the distribution record needs to be copied into a ticket or compared field by field.
    $ cat /etc/os-release
    PRETTY_NAME="Ubuntu 24.04.4 LTS"
    NAME="Ubuntu"
    VERSION_ID="24.04"
    VERSION="24.04.4 LTS (Noble Numbat)"
    VERSION_CODENAME=noble
    ID=ubuntu
    ID_LIKE=debian
    HOME_URL="https://www.ubuntu.com/"
    SUPPORT_URL="https://help.ubuntu.com/"
    BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
    PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
    UBUNTU_CODENAME=noble
    LOGO=ubuntu-logo

    If /etc/os-release is missing, read /usr/lib/os-release instead. Upstream guidance says applications should prefer /etc/os-release when it exists and fall back to the vendor file only when it does not.