hostname
-
Linux怎么快速设置主机名?
在 Linux 中设置永久主机名: ,1. 使用 sudo hostnamectl set-hostname 新主机名(推荐,立即生效)。 ,2. 或直接编辑 /etc/hostname 文件为 新主机名,保存后重启或运行 sudo systemctl restart systemd-hostnamed。 ,3. 同时确保 /etc/hosts 文件中的 127.0.0.1 行包含新主机名。
在 Linux 中设置永久主机名: ,1. 使用 sudo hostnamectl set-hostname 新主机名(推荐,立即生效)。 ,2. 或直接编辑 /etc/hostname 文件为 新主机名,保存后重启或运行 sudo systemctl restart systemd-hostnamed。 ,3. 同时确保 /etc/hosts 文件中的 127.0.0.1 行包含新主机名。