View a markdown version of this page

Using the os-release standard - Amazon Linux 2027
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Using the os-release standard

Amazon Linux complies with the os-release standard on the freedesktop.org website for identifying Linux distributions. This file provides machine-readable information about the operating system identification and version.

Note

The standard dictates that /etc/os-release is parsed first, followed by /usr/lib/os-release. Take care to follow the standard around file names and paths.

Key identification differences

The most reliable way to determine that an instance is running Amazon Linux is to check the ID field in os-release. On every version of Amazon Linux, the ID field is amzn.

The most reliable way to distinguish between Amazon Linux versions is to check the VERSION_ID field in os-release:

  • AL2027: VERSION_ID="2027"

  • AL2023: VERSION_ID="2023"

  • AL2: VERSION_ID="2"

Note

Remember that VERSION_ID is a machine-readable field intended for programmatic use, and PRETTY_NAME is designed for display to users. See Field types: machine-readable and human-readable for more information about field types.

Field types: machine-readable and human-readable

The /etc/os-release file (or /usr/lib/os-release if /etc/os-release does not exist) contains two types of fields: machine-readable fields intended for programmatic use, and human-readable fields intended for presentation to users.

Machine-readable fields

These fields use standardized formats and are intended for processing by scripts, package managers, and other automated tools. They contain only lowercase letters, numbers, and limited punctuation (periods, underscores, and hyphens).

  • ID – Operating system identifier. Amazon Linux uses amzn across all versions, distinguishing it from other distributions like Debian (debian), Ubuntu (ubuntu), or Fedora (fedora)

  • VERSION_ID – Operating system version for programmatic use, such as 2027

  • ID_LIKE – Space-separated list of related distributions, such as fedora

  • VERSION_CODENAME – Release codename for scripts

  • PLATFORM_ID – Platform identifier, such as platform:al2027

  • VARIANT_ID – Variant identifier for programmatic decisions

  • BUILD_ID – Build identifier for system images

  • IMAGE_ID – Image identifier for containerized environments

Human-readable fields

These fields are intended for display to users and can contain spaces, mixed case, and descriptive text. Use them when presenting operating system information in user interfaces.

  • NAME – Operating system name for display, such as Amazon Linux

  • PRETTY_NAME – Full operating system name with version for display, such as Amazon Linux 2027.0.20260903

  • VERSION – Version information suitable for user presentation

  • VARIANT – Variant or edition name for display, such as Server Edition

Other informational fields

These fields provide additional metadata about the operating system:

  • HOME_URL, DOCUMENTATION_URL, SUPPORT_URL, BUG_REPORT_URL – Project, documentation, support, and bug reporting URLs

  • VENDOR_NAME, VENDOR_URL – Vendor name and URL

  • SUPPORT_END – End-of-support date in YYYY-MM-DD format

  • CPE_NAME – Common Platform Enumeration identifier

  • ANSI_COLOR – ANSI color code for terminal display

Note

During the AL2027 preview, the informational URL fields and the SUPPORT_END field carry placeholder values. They will be finalized for the public releases.

When writing scripts or applications that need to identify Amazon Linux programmatically, use the machine-readable fields like ID and VERSION_ID. When displaying operating system information to users, use the human-readable fields like PRETTY_NAME.

/etc/os-release examples

The following examples show the identification fields from /etc/os-release on each Amazon Linux version:

AL2027
grep -E '^(NAME|VERSION|ID|ID_LIKE|VERSION_ID|PLATFORM_ID|PRETTY_NAME|CPE_NAME)=' /etc/os-release
NAME="Amazon Linux"
VERSION="2027"
ID="amzn"
ID_LIKE="fedora"
VERSION_ID="2027"
PLATFORM_ID="platform:al2027"
PRETTY_NAME="Amazon Linux 2027.0.20260903"
CPE_NAME="cpe:2.3:o:amazon:amazon_linux:2027:2027.0.20260903"
AL2023
grep -E '^(NAME|VERSION|ID|ID_LIKE|VERSION_ID|PLATFORM_ID|PRETTY_NAME|CPE_NAME)=' /etc/os-release
NAME="Amazon Linux"
VERSION="2023"
ID="amzn"
ID_LIKE="fedora"
VERSION_ID="2023"
PLATFORM_ID="platform:al2023"
PRETTY_NAME="Amazon Linux 2023.12.20260817"
CPE_NAME="cpe:2.3:o:amazon:amazon_linux:2023"
AL2
grep -E '^(NAME|VERSION|ID|ID_LIKE|VERSION_ID|PLATFORM_ID|PRETTY_NAME|CPE_NAME)=' /etc/os-release
NAME="Amazon Linux"
VERSION="2"
ID="amzn"
ID_LIKE="centos rhel fedora"
VERSION_ID="2"
PRETTY_NAME="Amazon Linux 2"
CPE_NAME="cpe:2.3:o:amazon:amazon_linux:2"

Comparison with other distributions

To understand how Amazon Linux fits within the broader Linux ecosystem, compare its identification fields with other major distributions:

Fedora
grep -E '^(NAME|VERSION|ID|ID_LIKE|VERSION_ID|PLATFORM_ID|PRETTY_NAME|CPE_NAME)=' /etc/os-release
NAME="Fedora Linux"
VERSION="43 (Container Image)"
ID=fedora
VERSION_ID=43
PLATFORM_ID="platform:f43"
PRETTY_NAME="Fedora Linux 43 (Container Image)"
CPE_NAME="cpe:/o:fedoraproject:fedora:43"
Debian
grep -E '^(NAME|VERSION|ID|ID_LIKE|VERSION_ID|PLATFORM_ID|PRETTY_NAME|CPE_NAME)=' /etc/os-release
PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
NAME="Debian GNU/Linux"
VERSION_ID="12"
VERSION="12 (bookworm)"
ID=debian
Ubuntu
grep -E '^(NAME|VERSION|ID|ID_LIKE|VERSION_ID|PLATFORM_ID|PRETTY_NAME|CPE_NAME)=' /etc/os-release
PRETTY_NAME="Ubuntu 24.04.4 LTS"
NAME="Ubuntu"
VERSION_ID="24.04"
VERSION="24.04.4 LTS (Noble Numbat)"
ID=ubuntu
ID_LIKE=debian

Notice how the machine-readable fields provide consistent identification across distributions:

  • ID – Uniquely identifies the operating system: amzn for Amazon Linux, fedora for Fedora, debian for Debian, ubuntu for Ubuntu

  • ID_LIKE – Shows distribution relationships: AL2027 and AL2023 use fedora, AL2 uses centos rhel fedora, and Ubuntu shows debian to indicate its Debian heritage

  • VERSION_ID – Provides machine-parseable version information: 2027 for AL2027, 43 for Fedora, 12 for Debian, 24.04 for Ubuntu

In contrast, the human-readable fields are designed for display to users:

  • NAME – User-friendly OS name: Amazon Linux, Fedora Linux, Debian GNU/Linux, Ubuntu

  • PRETTY_NAME – Complete display name with version: Amazon Linux 2027.0.20260903, Fedora Linux 43 (Container Image), Debian GNU/Linux 12 (bookworm), Ubuntu 24.04.4 LTS

  • VERSION – Human-readable version with additional context like codenames or release types

When writing cross-platform scripts, always use the machine-readable fields (ID, VERSION_ID, ID_LIKE) for logic and decisions, and use the human-readable fields (PRETTY_NAME, NAME) only for displaying information to users.