uname -n #或 hostname
hostname new_name
须要在新的终端中才能生效web
修改/etc/hostname文件便可,其它发行版本一般位于/etc/sysconfig/network。ubuntu
vim /etc/hostname
文件内容vim
server01
同时咱们能够设置主机名称和本地ip的映射经过修改/etc/hosts文件便可。bash
127.0.0.1 localhost 127.0.1.1 server01