How to modify the host name of Linux system

WBOY
Release: 2023-05-22 14:16:12
forward
26961 people have browsed it

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
Copy after login

2. Temporarily modify the host name

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

3. Permanently modify the host name Name

1. Method 1: Use the hostnamectl command

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

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

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

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!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!