Linux is a bit of a hassle, even modifying the hostname is no exception. Let's take a look at the specific methods below.
When Linux is installed, its default hostname is localhost. It takes 3 steps to modify the Linux host name.
Use hostname to modify the current host name.
Hostname new-hostname
Modify the/etc/sysconfig/network configuration file so that the next time you restart it, use the new host name.
Open a/etc/sysconfig/network file and modify Hostname=new-hostname.domainname.
The modified/etc/sysconfig/network file is as follows:
Networking=yes
Hostname=new-hostname.localdomain
Modify the native domain name resolution file/etc/hosts so that the native application can parse the new hostname.
Edit file:/etc/hosts
Modified: xxx.xxx.xxx.xxx new-hostname.domainname New-hostname
(Here XXX represents the network address of the machine, it can also be the loopback address 127.0.0.1)
The modified/etc/hosts file is as follows:
127.0.0.1 localhost.localdomain localhost
127.0.0.1 New-hostname.localdomain New-hostname
This article describes how to modify the hostname under the Linux system, actually know the method operation is very simple, I hope this article is helpful to everyone.
How to modify the Linux host name