- 修改vi /etc/hosts127.0.0.1 Server_China localhost.localdomain localhost
- 修改vi /etc/sysconfig/networkHOSTNAME=Server_China
- 输入下面命令生效#hostname Server_China
- centos7 设置主机名
#!/bin/bashif [ $# -ne 1 ];then echo `basename $0` "input hostname"else hostnamectl --static set-hostname $1 hostnamectl --transient set-hostname $1fi