[root@centos7 ~]$ hostnamectl set-hostname test.xyz.com # 使用这个命令会立即生效且重启也生效 [root@centos7 ~]$ hostname # 查看下 test.xyz.com