Using the os-release standard
Amazon Linux complies with the os-release
standard
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.
Topics
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 usesamznacross all versions, distinguishing it from other distributions like Debian (debian), Ubuntu (ubuntu), or Fedora (fedora) -
VERSION_ID– Operating system version for programmatic use, such as2027 -
ID_LIKE– Space-separated list of related distributions, such asfedora -
VERSION_CODENAME– Release codename for scripts -
PLATFORM_ID– Platform identifier, such asplatform: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 asAmazon Linux -
PRETTY_NAME– Full operating system name with version for display, such asAmazon Linux 2027.0.20260903 -
VERSION– Version information suitable for user presentation -
VARIANT– Variant or edition name for display, such asServer 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:
Comparison with other distributions
To understand how Amazon Linux fits within the broader Linux ecosystem, compare its identification fields with other major distributions:
Notice how the machine-readable fields provide consistent identification across distributions:
-
ID– Uniquely identifies the operating system:amznfor Amazon Linux,fedorafor Fedora,debianfor Debian,ubuntufor Ubuntu -
ID_LIKE– Shows distribution relationships: AL2027 and AL2023 usefedora, AL2 usescentos rhel fedora, and Ubuntu showsdebianto indicate its Debian heritage -
VERSION_ID– Provides machine-parseable version information:2027for AL2027,43for Fedora,12for Debian,24.04for 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.