显示当前主机名

  1. hostnamectl

image.png

更改系统主机名

  1. sudo hostnamectl set-hostname k8s-note2

image.png
静态主机名(hostname)存储在中/etc/hostname
image.png

主机名(hostname)映射

在大多数系统上,主机名(hostname)映射到127.0.0.1/etc/hosts。打开文件,将旧的主机名(hostname)更改为新的主机名(hostname)。
image.png
生效

  1. service network-manager restart
  2. # 重启网络
  3. systemctl network restart