

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# Amazon Linux 特定
<a name="ident-amazon-linux-specific"></a>

 有些檔案是 Amazon Linux 特有的，可用於識別 Amazon Linux 及其版本。新程式碼應使用 [`/etc/os-release`](ident-os-release.md)標準，以便與跨分佈相容。不鼓勵使用任何 Amazon Linux 特定檔案。

**Topics**
+ [`/etc/system-release` 檔案](#ident-system-release)
+ [影像識別檔案](#ident-image-id-file)
+ [Amazon Linux 特定檔案的範例](#ident-version-examples)

## `/etc/system-release` 檔案
<a name="ident-system-release"></a>

 Amazon Linux 包含 `/etc/system-release` 檔案，指定安裝的目前版本。此檔案使用套件管理員更新，Amazon Linux 是`system-release`套件的一部分。雖然 Fedora 等其他一些分佈也有此檔案，但它不存在於 Ubuntu 等以 Debian 為基礎的分佈中。

**注意**  
 `/etc/system-release` 檔案包含人類可讀取的字串，不應以程式設計方式用來識別作業系統或版本。請改用 `/etc/os-release`（或`/usr/lib/os-release`如果 `/etc/os-release` 不存在） 中的機器可讀取欄位。

 Amazon Linux 也包含機器可讀取的 版本`/etc/system-release`，其遵循 `/etc/system-release-cpe` 檔案中的通用平台列舉 (CPE) 規格。

## 影像識別檔案
<a name="ident-image-id-file"></a>

 每個 Amazon Linux 映像都包含一個唯一的`/etc/image-id`檔案，提供 Amazon Linux 團隊所產生之原始映像的其他資訊。此檔案專屬於 Amazon Linux，在其他 Linux 發行版本中找不到，例如 Debian、Ubuntu 或 Fedora。該檔案包含關於映像的下列資訊：
+ `image_name`、`image_version`、 `image_arch` – 用於建構映像之建置配方的值。
+ `image_stamp` – 在建立映像時產生的唯一隨機十六進位值。
+ `image_date` – 建立映像時的 UTC 時間，格式為 *YYYYMMDDhhmmss*。
+ `recipe_name`， `recipe_id` – 用於建構映像的建置配方的名稱和 ID。

## Amazon Linux 特定檔案的範例
<a name="ident-version-examples"></a>

 下列各節提供每個 Amazon Linux 主要版本之 Amazon Linux 特定識別檔案的範例。

**注意**  
在任何實際程式碼中，如果`/etc/os-release`檔案不存在，則`/usr/lib/os-release`應該使用 。

### AL2023
<a name="ident-image-id-amazon-linux-2023"></a>

下列範例顯示 AL2023 的識別檔案。

`/etc/image-id` 適用於 AL2023 的 範例：

```
[ec2-user ~]$ cat /etc/image-id
```

```
image_name="al2023-container"
image_version="2023"
image_arch="x86_64"
image_file="al2023-container-2023.8.20250721.2-x86_64"
image_stamp="822b-1a9e"
image_date="20250719211531"
recipe_name="al2023 container"
recipe_id="89b25f7b-be82-2215-a8eb-6e63-0830-94ea-658d41c4"
```

`/etc/system-release` 適用於 AL2023 的 範例：

```
[ec2-user ~]$ cat /etc/system-release
```

```
Amazon Linux release 2023.8.20250721 (Amazon Linux)
```

### AL2
<a name="ident-image-id-amazon-linux-2"></a>

下列範例顯示 AL2 的識別檔案。

`/etc/image-id` 適用於 AL2 的 範例：

```
[ec2-user ~]$ cat /etc/image-id
```

```
image_name="amzn2-container-raw"
image_version="2"
image_arch="x86_64"
image_file="amzn2-container-raw-2.0.20250721.2-x86_64"
image_stamp="4126-16ad"
image_date="20250721225801"
recipe_name="amzn2 container"
recipe_id="948422df-a4e6-5fc8-ba89-ef2e-0e1f-e1bb-16f84087"
```

`/etc/system-release` 適用於 AL2 的 範例：

```
[ec2-user ~]$ cat /etc/system-release
```

```
Amazon Linux release 2 (Karoo)
```

### Amazon Linux AMI
<a name="ident-image-id-amazon-linux-1"></a>

下列範例顯示 Amazon Linux AMI 的識別檔案。

適用於 Amazon Linux AMI `/etc/image-id`的 範例：

```
[ec2-user ~]$ cat /etc/image-id
```

```
image_name="amzn-container-minimal"
image_version="2018.03"
image_arch="x86_64"
image_file="amzn-container-minimal-2018.03.0.20231218.0-x86_64"
image_stamp="407d-5ef3"
image_date="20231218203210"
recipe_name="amzn container"
recipe_id="b1e7635e-14e3-dd57-b1ab-7351-edd0-d9e0-ca6852ea"
```

適用於 Amazon Linux AMI `/etc/system-release`的 範例：

```
[ec2-user ~]$ cat /etc/system-release
```

```
Amazon Linux AMI release 2018.03
```