How to change the host name in Linux

How to change the host name in Linux

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 # Temporarily modify the host name, which will become invalid after shutdown [root@fangjian ~]# hostname
yin

3. Permanently change the host name

1. Method 1: Use the hostnamectl command

[root@fangjian ~]# hostnamectl set-hostname Brace #Permanently set the user name, which will not expire after shutdown [root@fangjian ~]# hostname
brace

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

[root@fangjian ~]# vi /etc/hostname # Enter vi, delete the old host name, enter the new host name, Esc followed by a colon wq to exit and save the file. # reboot to take effect.

The above is a simple method to change the host name in Linux. If you have any additions, please contact the editor. Thank you for your support of 123WORDPRESS.COM.

You may also be interested in:
  • Detailed explanation of Linux host name modification command
  • How to permanently change the host name in Linux
  • How to modify the network card name and host name in Linux
  • Detailed introduction to linux host name configuration

<<:  Why is it not recommended to use index as key in react?

>>:  How to optimize MySQL deduplication operation to the extreme

Recommend

How to set focus on HTML elements

Copy code The code is as follows: <body <fo...

Can MySQL's repeatable read level solve phantom reads?

introduction When I was learning more about datab...

Double loading issue when the page contains img src

<br />When the page contains <img src=&qu...

Summary of HTML formatting standards for web-based email content

1. Page requirements 1) Use standard headers and ...

Solution to Linux CentOS 6.5 ifconfig cannot query IP

Recently, some friends said that after installing...

8 Reasons Why You Should Use Xfce Desktop Environment for Linux

For several reasons (including curiosity), I star...

5 Easy Ways to Free Up Space on Ubuntu

Preface Most people will probably perform this op...

Detailed explanation of JavaScript progress management

Table of contents Preface question principle test...

Detailed example of using case statement in MySQL stored procedure

This article uses an example to illustrate the us...

Div css naming standards css class naming rules (in line with SEO standards)

There are many tasks to be done in search engine o...

HTML table markup tutorial (28): cell border color attribute BORDERCOLOR

To beautify the table, you can set different bord...

7 skills that great graphic designers need to master

1》Be good at web design 2》Know how to design web p...

Analyzing the troublesome Aborted warning in MySQL through case studies

This article mainly introduces the relevant conte...