Skip to content

Latest commit

 

History

History
30 lines (18 loc) · 1.06 KB

hostname.md

File metadata and controls

30 lines (18 loc) · 1.06 KB

Hostname in Linux

hostnamectl status 可查看当前主机信息。

修改 hostname

  • 临时修改:hostname new-name
  • 永久修改: hostnamectl set-hostname new-name 或者修改 /etc/hostname 文件。

hostname 定义在以下这些文件

  • /etc/hosts for networking
  • /etc/hostname : This will be read by boot scripts on boot time and set its value.
  • /proc/sys/kernel/hostname : Current hostname.
  • /etc/sysconfig/network : Networking (HOSTNAME=”server1″ parameter)

修改文件后需要重启系统。

参考文章

关于 FQDN

FQDN 定义: https://www.wikiwand.com/en/Fully_qualified_domain_name

python 2.x 中 socket 库 socket.getfqdn() 调用的是 hostname --all-fqdsn。可能会有坑。

参考 Issue: https://bugs.python.org/issue5004