LoginSignup
0
0

More than 3 years have passed since last update.

hostname 変更あれこれ

Posted at

はじめに

変更方法はいろいろあるみたい

/etc/hostnameによる変更

$ hostname
ubuntu20
$ vim hostname

- ubuntu20
+ linux

$ sudo systemctl restart systemd-hostnamed
$ hostname
linux
$ sudo shutdown -r now
 .
 .
 .
$ hostname
linux

hostnameコマンドによる変更(再起動でもとに戻る)

$ hostname
ubuntu20
$ sudo hostname linux
$ hostname
linux
$ cat /etc/hostname
ubuntu20
$ sudo shutdown -r now
 .
 .
 .
$ hostname
ubuntu20

hostnamectlによる変更

$ hostname
ubuntu20
$ sudo hostnamectl set-hostname linux
$ hostname
linux
$ cat /etc/hostname
linux
$ sudo shutdown -r now
 .
 .
 .
$ hostname
linux

nmcliによる変更

$ hostname
ubuntu20
$ sudo nmcli gen hostname linux
$ hostname
linux
$ cat /etc/hostname
linux
$ sudo shutdown -r now
 .
 .
 .
$ hostname
linux

nmtuiによる設定

$ hostname
ubuntu20
$ sudo nmtui

"Set system hostname" を選択

image.png

host名を入力

image.png

OK

image.png

$ hostname
linux
$ cat /etc/hostname
linux
$ sudo shutdown -r now
 .
 .
 .
$ hostname
linux
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0