﻿# 如何查詢 Linux 的種類與版本 ( Linux Standard Base )

我所經手的 Linux 版本還蠻多元的，有 Fedora, RedHat, Ubuntu, ... 等，且有時後客戶讓我登入他們的 Linux 主機，我第一件事也是先查詢該主機的 Linux 種類與版本，得知 Linux 的種類與版本可以協助我判斷各種不同的 Distribution 之間不同的特性，例如安裝套件時要用 yum 或 apt-get 之類的，各家的 Linux 散佈(distribution) 有時候一些管理指令與預設目錄還差蠻多的。

在 Linux 界有個 [Linux Standard Base](https://refspecs.linuxfoundation.org/lsb.shtml) 規格 (簡稱 LSB)，這裡定義了各家 Linux 散佈之間必須共通的規範，否則 Linux 因為是開放原始碼的作業系統，如果真的各自做各自的，有一天一定天下大亂。

也正好 LSB 有定義一個 [lsb\_release](http://refspecs.linuxfoundation.org/LSB_3.1.0/LSB-Core-generic/LSB-Core-generic/lsbrelease.html) 指令可以查詢 Linux 散佈版本資訊 ( Distribution information )，例如以下指令執行範例：

```
[root@localhost ~]# lsb_release -a
LSB Version:    1.3
Distributor ID: FedoraCore
Description:    Fedora Core release 3 (Heidelberg)
Release:        3
Codename:       Heidelberg
```

所以你以後在登入任何有通過 LSB 認證的 Linux distribution 時，就可以透過 lsb\_release -a 進行版本查詢了！

**相關連結**

-   [Linux Standard Base - Wikipedia, the free encyclopedia](http://en.wikipedia.org/wiki/Linux_Standard_Base)
-   [lsb\_release](http://refspecs.linuxfoundation.org/LSB_3.1.0/LSB-Core-generic/LSB-Core-generic/lsbrelease.html)
