You can view and modify the Host Name of centos7 in centos7. There are three defined host names:
- Static hostname)
- The "static" host name is also called the kernel host name. It is the host name automatically initialized from/etc/hostname at startup.
- Transient (tansient hostname)
- The "transient" host name is a temporary host name allocated during system operation, such as through DHCP or mdns server.
- Flexible (pretty hostname)
- "Flexible" host names are also called "alias" host names.
"Flexible" host names are allowed to be displayed to end users (such as [email protected]) in a free form (including special/blank characters).
Both "static" and "transient" host names follow the same character restriction rules as Internet domain names.
View and modify host names
- Hostnamectl command line tool that allows you to view or modify host name-related configurations.
- Run the hostnamectl command to view the host name.
- Modify host name
- Temporary valid command: Hostname xh01
- Valid permanently
// You can change the host name permanently. Hostnamectl set-hostname XXX // Delete hostnamehostnamectl set-hostname "" hostnamectl set-hostname "" -- statichostnamectl set-hostname "" -- pretty
- You can also manually modify the/etc/hostname file.
- Configure the/etc/hosts file
// Example 127.0.0.1 localhost192.168.126.128 s201192.168.126.129 s202192.168.126.130 s203192.168.126.131 s204 // test the Modification result Ping s201
View and modify the Host Name of centos7