CentOS7中有三種定義的主機(jī)名:
靜態(tài)的(static)、瞬態(tài)的(transient)、和靈活的(pretty)。
靜態(tài)主機(jī)名也稱為內(nèi)核主機(jī)名,是系統(tǒng)在啟動(dòng)時(shí)從/etc/hostname內(nèi)自動(dòng)初始化的主機(jī)名。
瞬態(tài)主機(jī)名是在系統(tǒng)運(yùn)行時(shí)臨時(shí)分配的主機(jī)名。
靈活主機(jī)名則允許使用特殊字符的主機(jī)名.
1、查看
#hostnamectl
或者
#hostnamectl status
2、設(shè)置
設(shè)置 瞬態(tài)
#hostnamectl --transient set-hostname centos7
設(shè)置 靜態(tài)
#hostnamectl --transient set-hostname centos7
設(shè)置 靈活
#hostnamectl --transient set-hostname centos7