Home  >  Article  >  Operation and Maintenance  >  How to modify the host name of Linux system

How to modify the host name of Linux system

WBOY
WBOYforward
2023-05-22 14:16:1227000browse

1. View the current host name

[root@fangjian ~]# hostnamectl
  static hostname: brace
  pretty hostname: brace
     icon name: computer-vm
      chassis: vm
    machine id: 20191225111607875619293640639763
      boot id: 25ac5021d229471382a26bea3d351de3
  virtualization: kvm
 operating system: centos linux 7 (core)
    cpe os name: cpe:/o:centos:centos:7
      kernel: linux 3.10.0-1062.9.1.el7.x86_64
   architecture: x86-64

2. Temporarily modify the host name

[root@fangjian ~]# hostname yin  #临时修改主机名,关机后失效
[root@fangjian ~]# hostname
yin

3. Permanently modify the host name Name

1. Method 1: Use the hostnamectl command

[root@fangjian ~]# hostnamectl set-hostname brace #永久设置用户名,关机后不失效
[root@fangjian ~]# hostname
brace

2. Method 2: Modify the configuration file /etc/hostname, save and exit

[root@fangjian ~]# vi /etc/hostname  # 进入vi,删除旧主机名,输入新主机名,esc后冒号 wq退出保存
brace                  # reboot重启生效

The above is the detailed content of How to modify the host name of Linux system. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete