1.在安装操作系统的时候设定好主机名2.直接使用文本编辑器修改/etc/hostname配置文件。3.使用hostnamectl命令,hostnamectl set-hostname name ,再通过hostname或者hostnamectl status命令查看更改是否生效。