Ubuntu 22.04 LTSにホスト名を設定する方法
環境
OSバージョンを確認します
# 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.一時的にホスト名を変更します
現在のホスト名を確認します
# hostname
arte-virtual-machine
ホスト名を変更します
# hostname arkgame
# hostname
arkgame
# hostname arkgame
# hostname
arkgame
# hostname arkgame # hostname arkgame
2.恒久的にホスト名を変更します
# hostnamectl set-hostname arkgame.com
# hostnamectl
結果
Static hostname: arkgame.com
Icon name: computer-vm
Chassis: vm
Machine ID: d45181098ce84749b1874e130eb125cf
Boot ID: ef881981d62b43528546f197a0c2164d
Virtualization: vmware
Operating System: Ubuntu 22.04 LTS
Kernel: Linux 5.15.0-33-generic
Architecture: x86-64
Hardware Vendor: VMware, Inc.
Hardware Model: VMware Virtual Platform
Static hostname: arkgame.com
Icon name: computer-vm
Chassis: vm
Machine ID: d45181098ce84749b1874e130eb125cf
Boot ID: ef881981d62b43528546f197a0c2164d
Virtualization: vmware
Operating System: Ubuntu 22.04 LTS
Kernel: Linux 5.15.0-33-generic
Architecture: x86-64
Hardware Vendor: VMware, Inc.
Hardware Model: VMware Virtual Platform
Static hostname: arkgame.com Icon name: computer-vm Chassis: vm Machine ID: d45181098ce84749b1874e130eb125cf Boot ID: ef881981d62b43528546f197a0c2164d Virtualization: vmware Operating System: Ubuntu 22.04 LTS Kernel: Linux 5.15.0-33-generic Architecture: x86-64 Hardware Vendor: VMware, Inc. Hardware Model: VMware Virtual Platform