Ubuntu バージョン確認方法

Ubuntu バージョン確認方法

ubuntuのバージョン確認手順を記述してます。確認方法はいくつかありますが、「cat」で「/etc/issue」ファイルを確認するか「hostnamectl」コマンドが一番簡単です。GUIからも確認することは可能です。

環境

  • OS ubuntu20.04

バージョン確認方法

「/etc/issue」ファイルを「cat」で確認することで、「Ubuntu(ウブントゥ)」のバージョンは確認できます。

$ cat /etc/issue

<出力結果 20.04の場合>
Ubuntu 20.04 LTS \n \l

<出力結果 21.10の場合>
Ubuntu 21.10 \n \l

<出力結果 22.04の場合>
Ubuntu 22.04.1 LTS \n \l

<出力結果 22.10の場合>
Ubuntu 22.10 \n \l

<出力結果 23.10の場合>
Ubuntu 23.10 \n \l

「lsb-release」パッケージ

また、「lsb-release」パッケージを確認する方法もあります。
こちらの方法でも、「Ubuntu」のバージョンやコードネームも確認できます。

$ cat /etc/lsb-release

<出力結果 20.04の場合>
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=20.04
DISTRIB_CODENAME=focal
DISTRIB_DESCRIPTION="Ubuntu 20.04 LTS"

<出力結果 21.10の場合>
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=21.10
DISTRIB_CODENAME=impish
DISTRIB_DESCRIPTION="Ubuntu 21.10"

<出力結果 22.04の場合>
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04.1 LTS"

<出力結果 22.10の場合>
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.10
DISTRIB_CODENAME=kinetic
DISTRIB_DESCRIPTION="Ubuntu 22.10"

「/etc/os-release」ファイル

他には「/etc/os-release」ファイルで「OS情報」を確認して、「Ubuntu」のバージョンを確認することもできます。

$ cat /etc/os-release

<出力結果 19.04の場合>
NAME="Ubuntu"
VERSION="19.04 (Disco Dingo)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 19.04"
VERSION_ID="19.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=disco
UBUNTU_CODENAME=disco

<出力結果 21.10の場合>
PRETTY_NAME="Ubuntu 21.10"
NAME="Ubuntu"
VERSION_ID="21.10"
VERSION="21.10 (Impish Indri)"
VERSION_CODENAME=impish
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=impish

<出力結果 22.04の場合>
PRETTY_NAME="Ubuntu 22.04.1 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.1 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy

「lsb_release」コマンド

「lsb_release」コマンドでも確認できます。

$ lsb_release -a

<出力結果 20.04の場合>
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04 LTS
Release:        20.04
Codename:       focal

<出力結果 21.10の場合>
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 21.10
Release:        21.10
Codename:       impish

<出力結果 22.04の場合>
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.1 LTS
Release:        22.04
Codename:       jammy

「hostnamectl」コマンド

ホスト名を設定するのに使用するコマンドである「hostnamectl」でも確認できます。

$ hostnamectl

<出力結果 19.04の場合>
   Static hostname: testuser-FMVA2201AP
         Icon name: computer-laptop
           Chassis: laptop
        Machine ID: 12a6f957853e4a858b3eda41c3978c3e
           Boot ID: ca5aa4faaf7943d3b4bdd6bfa76dcbb4
  Operating System: Ubuntu 19.04
            Kernel: Linux 5.0.0-38-generic
      Architecture: x86-64

<出力結果 21.10の場合>
 Static hostname: testuser-Virtual-Machine
       Icon name: computer-vm
         Chassis: vm
      Machine ID: 9ada5bda523c479b8d0e43e849cabb64
         Boot ID: 4a2ff6bbd98d49e9bb5ff0a732958896
  Virtualization: microsoft
Operating System: Ubuntu 21.10                    
          Kernel: Linux 5.13.0-22-generic
    Architecture: x86-64
 Hardware Vendor: Microsoft Corporation
  Hardware Model: Virtual Machine

<出力結果 22.04の場合>
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.1 LTS
Release:        22.04
Codename:       jammy
hoge@hoge-Default-string:~$ hostnamectl
 Static hostname: hoge-Default-string
       Icon name: computer-laptop
         Chassis: laptop
      Machine ID: 9a177cc8f5a54194906ce63c4a5a5e7f
         Boot ID: 532dca8a38f54495b5682e402e6b25b7
Operating System: Ubuntu 22.04.1 LTS
          Kernel: Linux 5.15.0-53-generic
    Architecture: x86-64
 Hardware Vendor: Default string
  Hardware Model: Default string

「grep」すれば、バージョンだけを取得できます。

$ hostnamectl | grep "Operating System"

<出力結果 21.10の場合>
Operating System: Ubuntu 21.10

GUIで確認

GUIから確認するには、まずは「設定」を選択します。
※画面は、Ubuntu21.10を使用してます。

「このシステムについて」より確認できます。

「Ubuntu 22.04」も場合も同じ方法で確認できます。

screenfetch

ネタになりますが、「screenfetch」という「Ubuntu」のロゴのスクリーンアートを表示するパッケージを使用して確認もできます。

インストールは「apt」で可能です。

$ sudo apt install screenfetch

実行すると以下のようにロゴのスクリーンアートが表示されバージョンも確認できます。

$ screenfetch
                          ./+o+-       testuser@testuser-Virtual-Machine
                  yyyyy- -yyyyyy+      OS: Ubuntu 22.10 kinetic
               ://+//////-yyyyyyo      Kernel: x86_64 Linux 5.19.0-26-generic
           .++ .:/++++++/-.+sss/`      Uptime: 23h 16m
         .:++o:  /++++++++/:--:/-      Packages: 1774
        o:+o+:++.`..```.-/oo+++++/     Shell: bash
       .:+o:+o/.          `+sssoo+/    Disk: 15G / 295G (6%)
  .++/+:+oo+o:`             /sssooo.   CPU: Intel Xeon E3-1225 v6 @ 3.312GHz
 /+++//+:`oo+o               /::--:.   RAM: 2777MiB / 5725MiB
 \+/+o+++`o++o               ++////.  
  .++.o+++oo+:`             /dddhhh.  
       .+.o+oo:.          `oddhhhh+   
        \+.++o+o``-````.:ohdhhhhh+    
         `:o+++ `ohhhhhhhhyo++os:     
           .o:`.syhhhhhhh/.oo++o`     
               /osyyyyyyo++ooo+++/    
                   ````` +oo+++o\:    
                          `oo++.  

実際の画像は、以下となります。

カーネルバージョンを確認

バージョンとは異なりますが、カーネルのバージョンを確認する場合は「uname -r」を使用します。

$ uname -r

5.13.0-22-generic

アーキテクチャを確認

アーキテクチャを確認する場合は、「arch」を使用します。

$ arch

x86_64