CentOS7 修改 主机名 localhost

看别人的主机名都localhost很顺眼,新装的系统主机名却是MiWiFi-R1CM-srv

[jerryjin@MiWiFi-R1CM-srv ~]$ hostnamectl
   Static hostname: localhost
Transient hostname: MiWiFi-R1CM-srv
         Icon name: computer-laptop
           Chassis: laptop
        Machine ID: 0bc8c4156d6440b48c9af2b3dc87c429
           Boot ID: 953e81f755334863ba2750e671c94321
  Operating System: CentOS Linux 7 (Core)
       CPE OS Name: cpe:/o:centos:centos:7
            Kernel: Linux 3.10.0-957.12.2.el7.x86_64
      Architecture: x86-64

主要用到这个命令hostnamectl

[jerryjin@MiWiFi-R1CM-srv ~]$ hostnamectl --help
hostnamectl [OPTIONS...] COMMAND ...

Query or change system hostname.

  -h --help              Show this help
     --version           Show package version
     --no-ask-password   Do not prompt for password
  -H --host=[USER@]HOST  Operate on remote host
  -M --machine=CONTAINER Operate on local container
     --transient         Only set transient hostname
     --static            Only set static hostname
     --pretty            Only set pretty hostname

Commands:
  status                 Show current hostname settings
  set-hostname NAME      Set system hostname
  set-icon-name NAME     Set icon name for host
  set-chassis NAME       Set chassis type for host
  set-deployment NAME    Set deployment environment for host
  set-location NAME      Set location for host

要同时修改:静态主机名、瞬态主机名、灵活主机名

[jerryjin@MiWiFi-R1CM-srv ~]$ hostnamectl set-hostname localhost

只修改瞬态主机名

[jerryjin@MiWiFi-R1CM-srv ~]$ hostnamectl --transient set-hostname localhost

重点重点改完你要关闭当前 ,在打开的新的终端窗口,主机名就是新的了。
CentOS7 修改 主机名 localhost_第1张图片

你可能感兴趣的:(#,Linux)