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

Brief analysis of MySQL union and union all

In the database, both UNION and UNION ALL keyword...

Users need to know why

When I was in the securities company, because the ...

Distributed monitoring system Zabbix uses SNMP and JMX channels to collect data

In the previous article, we learned about the pas...

Examples of correct use of interface and type methods in TypeScript

Table of contents Preface interface type Appendix...

HTML text escape tips

Today I saw a little trick for HTML text escaping ...

MySQL view introduction and basic operation tutorial

Preface View is a very useful database object in ...

JavaScript web form function communication full of practical information

1. Introduction Earlier we talked about the front...

Example of how to change the domestic source in Ubuntu 18.04

Ubuntu's own source is from China, so the dow...

Solution to the conflict between two tabs navigation in HTML

Let's start with a description of the problem...

Perfect solution to Google Chrome autofill problem

In Google Chrome, after successful login, Google ...

Implementation of grayscale release with Nginx and Lua

Install memcached yum install -y memcached #Start...

VMware Tools installation and configuration tutorial for Ubuntu 18.04

This article records the installation and configu...