Ubuntu:ホスト名を変更
hostnamectl コマンドを使う。
引数無しで使うと、現在の情報を表示してくれる。
takatoh@envelopes $ hostnamectl
Static hostname: envelopes
Icon name: computer-desktop
Chassis: desktop
Machine ID: 51e97893a0e54d888a7bc435e3cb10be
Boot ID: 528cc17f21ef4185b0697228e4d092b5
Operating System: Ubuntu 16.04.5 LTS
Kernel: Linux 4.4.0-133-generic
Architecture: x86-64
hostnamectl set-hostname コマンドでホスト名変更。
takatoh@envelopes $ sudo hostnamectl set-hostname apostrophe
[sudo] takatoh のパスワード:
確認。
takatoh@envelopes $ hostnamectl
Static hostname: apostrophe
Icon name: computer-desktop
Chassis: desktop
Machine ID: 51e97893a0e54d888a7bc435e3cb10be
Boot ID: 528cc17f21ef4185b0697228e4d092b5
Operating System: Ubuntu 16.04.5 LTS
Kernel: Linux 4.4.0-133-generic
Architecture: x86-64
ちゃんと変わっている。 /etc/hosts ファイルを編集。
127.0.0.1 localhost
127.0.1.1 apostrophe # ←ここを修正した。
192.168.1.21 muffinman
192.168.1.15 montana
192.168.1.6 wplj
(以下略)
ネットワークの再起動。
takatoh@envelopes $ sudo service networking restart
これでOK。プロンプトのホスト名が変わっていないけど、これは端末を起動し直すと直る。
