Ubuntu 22.04 LTSのホスト名を変更する方法

環境
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.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04.1 LTS"
# cat /etc/lsb-release DISTRIB_ID=Ubuntu DISTRIB_RELEASE=22.04 DISTRIB_CODENAME=jammy DISTRIB_DESCRIPTION="Ubuntu 22.04.1 LTS"
# cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04.1 LTS"

構文
hostnamectl set-hostname 新しいホスト名

操作例
1.ホスト名を「arkgame」に変更します

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-vm
Chassis: vm
Machine ID: 444cc442f43d4ba78b07f36d4ba33b23
Boot ID: b10220584b6e4b5094e967e803abdf42
Virtualization: vmware
Operating System: Ubuntu 22.04.1 LTS
Kernel: Linux 5.15.0-52-generic
Architecture: x86-64
# hostnamectl Static hostname: arkgame Icon name: computer-vm Chassis: vm Machine ID: 444cc442f43d4ba78b07f36d4ba33b23 Boot ID: b10220584b6e4b5094e967e803abdf42 Virtualization: vmware Operating System: Ubuntu 22.04.1 LTS Kernel: Linux 5.15.0-52-generic Architecture: x86-64
# hostnamectl
 Static hostname: arkgame
       Icon name: computer-vm
         Chassis: vm
      Machine ID: 444cc442f43d4ba78b07f36d4ba33b23
         Boot ID: b10220584b6e4b5094e967e803abdf42
  Virtualization: vmware
Operating System: Ubuntu 22.04.1 LTS
          Kernel: Linux 5.15.0-52-generic
    Architecture: x86-64

 

Ubuntu 22.04

Posted by arkgame