How to modify the hostname in Linux
How to modify the Linux hostname? You can temporarily modify the host name, but after the Linux server restarts, the host name becomes invalid. There is another way to permanently modify the hostname, which remains valid whether Linux is restarted or not. Let's talk about both methods:
Method for temporarily modifying Linux host names
Setting: Temporarily modify the host name to linuxbaike
Command: hostname linuxbaike
Did you find no changes after executing the command? Simply reopen the terminal to display it, or you can use the uname - n command to view the current hostname.
Methods for permanently modifying Linux host names
Permanently modify the Linux host name, and the host name remains unchanged after restarting the Linux server.
By modifying the configuration file:/ etc/sysconfig/network
Execute command: vi /etc/sysconfig/network, Just change hostname=to the name you want.
After modification, save it and then restart the server operating system to test if the hostname has been permanently modified?
Regarding the hosts file
Regarding the hosts file:/ The etc/hosts file provides a function for domain name resolution, similar to DNS. When a Linux system sends a domain name resolution request to a DNS server, it queries the/etc/hosts file. So, generally changing the host name does not require modifying the hosts file.
In summary, to permanently modify the Linux hostname, simply modify the/etc/sysconfig/network file.
- linux, 修改主机名, 修改服务器名, hostname
- 0 Users Found This Useful