Ubuntuのホスト名を変更する
はじめに
ubuntuサーバにログイン後、サーバ名を識別するために、ホスト名を変更する。
ホスト名の確認
以下のコマンドを実行し、現在のホスト名を確認する。
1 2 3 4 5 6 7 8 9 |
ubuntu@ubuntu:~$ hostnamectl Static hostname: ubuntu Icon name: computer Machine ID: 7d9ce2a2cd1247f7b99d8b4f623da378 Boot ID: 653f10eae14242b2a352e204c63c9369 Operating System: Ubuntu 20.04.2 LTS Kernel: Linux 5.4.0-1034-raspi Architecture: arm64 ubuntu@ubuntu:~$ |
出力結果よりホスト名が確認出来た。
ホスト名の変更
以下のコマンドでホスト名を変更する。
1 |
sudo hostnamectl set-hostname ホスト名 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
#ホスト名の変更 ubuntu@ubuntu:~$ sudo hostnamectl set-hostname RAS-SRV #変更後のホスト名の変更 ubuntu@ubuntu:~$ hostnamectl Static hostname: RAS-SRV Icon name: computer Machine ID: 7d9ce2a2cd1247f7b99d8b4f623da378 Boot ID: 653f10eae14242b2a352e204c63c9369 Operating System: Ubuntu 20.04.2 LTS Kernel: Linux 5.4.0-1034-raspi Architecture: arm64 #環境変数の確認 ubuntu@ubuntu:~$ hostname RAS-SRV ubuntu@ubuntu:~$ |
以上で、ホスト名の変更が完了