Ubuntuはホスト名をプロンプトに表示します。とあり合えずインストールしておいて、後で変えたいことも多々あります。
Ubuntuの場合は以下のコマンドで簡単に変更できます。ただ、/etc/hostsの中のネットワーク上のホスト名は変わらないので、手動で編集しました。
takumi@easyrast1:~$ sudo hostnamectl set-hostname rasgwtkm01
takumi@easyrast1:~$ sudo -i
root@rasgwtkm01:~# reboot
Connection to 192.168.0.54 closed by remote host.
Connection to 192.168.0.54 closed.
PS C:\Users\taniy> ssh takumi@192.168.0.54
takumi@192.168.0.54's password:
Welcome to Ubuntu 20.04.3 LTS (GNU/Linux 5.4.0-81-generic x86_64)
Last login: Sat Sep 4 06:46:28 2021 from 192.168.0.36
takumi@rasgwtkm01:~$
takumi@rasgwtkm01:~$ cat /etc/hosts
127.0.0.1 localhost
127.0.1.1 easyrast1
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
takumi@rasgwtkm01:~$ sudo cp -a /etc/hosts{,.20210904}
[sudo] password for takumi:
takumi@rasgwtkm01:~$ sudo nano /etc/hosts
takumi@rasgwtkm01:~$ sudo diff /etc/hosts{,.20210904}
2c2
< 127.0.1.1 rasgwtkm01
---
> 127.0.1.1 easyrast1
takumi@rasgwtkm01:~$
takumi@easyrast1:~$ sudo -i
root@rasgwtkm01:~# reboot
Connection to 192.168.0.54 closed by remote host.
Connection to 192.168.0.54 closed.
PS C:\Users\taniy> ssh takumi@192.168.0.54
takumi@192.168.0.54's password:
Welcome to Ubuntu 20.04.3 LTS (GNU/Linux 5.4.0-81-generic x86_64)
Last login: Sat Sep 4 06:46:28 2021 from 192.168.0.36
takumi@rasgwtkm01:~$
takumi@rasgwtkm01:~$ cat /etc/hosts
127.0.0.1 localhost
127.0.1.1 easyrast1
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
takumi@rasgwtkm01:~$ sudo cp -a /etc/hosts{,.20210904}
[sudo] password for takumi:
takumi@rasgwtkm01:~$ sudo nano /etc/hosts
takumi@rasgwtkm01:~$ sudo diff /etc/hosts{,.20210904}
2c2
< 127.0.1.1 rasgwtkm01
---
> 127.0.1.1 easyrast1
takumi@rasgwtkm01:~$
いつもアクセスありがとうございます。Ubuntuのホスト名の変更方法を共有します。引き続き、よろしくお願いします。