Using the os-release standard
Amazon Linux complies with the
os-release standard
Note
The standard dictates that /etc/os-release is attempted to
be parsed first, followed by /usr/lib/os-release. Care should
be taken to follow the standard around file names and paths.
Topics
Key identification differences
The os-release is found at /etc/os-release,
and if that is not present, at /usr/lib/os-release. Consult the
os-release standard
The most reliable way to determine an instance is running Amazon Linux is to check the
ID field in os-release.
The most reliable way to determine distinguish between versions is to check the
VERSION_ID field in os-release:
-
Amazon Linux AMI:
VERSION_IDcontains a date-based version (e.g.,2018.03) -
AL2:
VERSION_ID="2" -
AL2023:
VERSION_ID="2023"
Note
Remember that VERSION_ID is a machine-readable field intended for programmatic use,
while PRETTY_NAME is designed for display to users. See
Field types: Machine-readable vs. Human-readable for more information about field types.
Field types: Machine-readable vs. 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 (e.g.,2023) -
ID_LIKE– Space-separated list of related distributions (e.g.,fedora) -
VERSION_CODENAME– Release codename for scripts (e.g.,karoo) -
VARIANT_ID– Variant identifier for programmatic decisions -
BUILD_ID– Build identifier for system images -
IMAGE_ID– Image identifier for containerized environments -
PLATFORM_ID– Platform identifier (e.g.,platform:al2023)
Human-readable fields
These fields are intended for display to users and may contain spaces, mixed case, and descriptive text. They should be used when presenting operating system information in user interfaces.
-
NAME– Operating system name for display (e.g.,Amazon Linux) -
PRETTY_NAME– Full operating system name with version for display (e.g.,Amazon Linux 2023.8.20250721) -
VERSION– Version information suitable for user presentation -
VARIANT– Variant or edition name for display (e.g.,Server Edition)
Other informational fields
These fields provide additional metadata about the operating system:
-
HOME_URL– Project homepage URL -
DOCUMENTATION_URL– Documentation URL -
SUPPORT_URL– Support information URL -
BUG_REPORT_URL– Bug reporting URL -
VENDOR_NAME– Vendor name -
VENDOR_URL– Vendor 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
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 /etc/os-release file content varies between Amazon Linux versions:
Comparison with other distributions
To understand how Amazon Linux fits within the broader Linux ecosystem, compare its
/etc/os-release format 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: Amazon Linux usesfedora(AL2023) orcentos rhel fedora(AL2), while Ubuntu showsdebianto indicate its Debian heritage -
VERSION_ID– Provides machine-parseable version information:2023for AL2023,42for 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 2023.8.20250721,Fedora Linux 42 (Container Image),Debian GNU/Linux 12 (bookworm),Ubuntu 24.04.2 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.