Ubuntu 22.04 LTSにホスト名を設定する方法

環境

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 LTS"
$ cat /etc/lsb-release DISTRIB_ID=Ubuntu DISTRIB_RELEASE=22.04 DISTRIB_CODENAME=jammy DISTRIB_DESCRIPTION="Ubuntu 22.04 LTS"
$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04 LTS"

操作方法
1.現在のホスト名を表示

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# hostname
arte-virtual-machine
# hostname arte-virtual-machine
# hostname
arte-virtual-machine

2.恒久的にホスト名を変更します

書式
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

3.設定を確認します

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: 532eadb123954a58bd8ccf1ea707109d
Virtualization: vmware
Operating System: Ubuntu 22.04 LTS
Kernel: Linux 5.15.0-40-generic
Architecture: x86-64
Hardware Vendor: VMware, Inc.
Hardware Model: VMware Virtual Platform
# hostnamectl Static hostname: arkgame Icon name: computer-vm Chassis: vm Machine ID: 444cc442f43d4ba78b07f36d4ba33b23 Boot ID: 532eadb123954a58bd8ccf1ea707109d Virtualization: vmware Operating System: Ubuntu 22.04 LTS Kernel: Linux 5.15.0-40-generic Architecture: x86-64 Hardware Vendor: VMware, Inc. Hardware Model: VMware Virtual Platform
# hostnamectl
 Static hostname: arkgame
       Icon name: computer-vm
         Chassis: vm
      Machine ID: 444cc442f43d4ba78b07f36d4ba33b23
         Boot ID: 532eadb123954a58bd8ccf1ea707109d
  Virtualization: vmware
Operating System: Ubuntu 22.04 LTS
          Kernel: Linux 5.15.0-40-generic
    Architecture: x86-64
 Hardware Vendor: VMware, Inc.
  Hardware Model: VMware Virtual Platform

 

Ubuntu 22.04

Posted by arkgame