Ubuntu 22.10 ホスト名を変更する方法

環境
OSバージョンを確認します

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.10
DISTRIB_CODENAME=kinetic
DISTRIB_DESCRIPTION="Ubuntu 22.10"
# cat /etc/lsb-release DISTRIB_ID=Ubuntu DISTRIB_RELEASE=22.10 DISTRIB_CODENAME=kinetic DISTRIB_DESCRIPTION="Ubuntu 22.10"
# cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.10
DISTRIB_CODENAME=kinetic
DISTRIB_DESCRIPTION="Ubuntu 22.10"

操作方法
1.コマンドでホスト名を変更するには、以下のコマンドを実行します。
書式
hostnamectl set-hostname 新しいホスト名
操作例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# hostnamectl set-hostname arkgame
# hostnamectl set-hostname arkgame
# hostnamectl set-hostname arkgame

2.ホスト名を表示します
「hostnamectl」を引数なしで実行すると、ホスト名のほか、以下のように各種情報が出力されます。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
$ hostnamectl
Static hostname: arkgame
Icon name: computer
Machine ID: 04b66ec3c2e14b8099adcb3dfdb6cc62
Boot ID: b47b6d7c8ee44eb1be80aa526e8a694a
Virtualization: vmware
Operating System: Ubuntu 22.10
Kernel: Linux 5.19.0-23-generic
Architecture: x86-64
Firmware Version: 6.00
$ hostnamectl Static hostname: arkgame Icon name: computer Machine ID: 04b66ec3c2e14b8099adcb3dfdb6cc62 Boot ID: b47b6d7c8ee44eb1be80aa526e8a694a Virtualization: vmware Operating System: Ubuntu 22.10 Kernel: Linux 5.19.0-23-generic Architecture: x86-64 Firmware Version: 6.00
$ hostnamectl
 Static hostname: arkgame
       Icon name: computer
      Machine ID: 04b66ec3c2e14b8099adcb3dfdb6cc62
         Boot ID: b47b6d7c8ee44eb1be80aa526e8a694a
  Virtualization: vmware
Operating System: Ubuntu 22.10
          Kernel: Linux 5.19.0-23-generic
    Architecture: x86-64
Firmware Version: 6.00

 

Ubuntu 22.10

Posted by arkgame