Method for modifying server hostname in Linux system

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.

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

Simple Method for Setting Linux VPS System Synchronization Time and Time Zone

80% of VPS users may choose their preferred system directly after purchasing VPS, and then...

The meaning and characteristics of the. io suffix domain name, as well as its suitability for the domain (whether it is worth registering)

IO is the abbreviation for British Indian Ocean Territory, therefore the. io domain is also...

How to modify server DNS address in Linux

DNS is a server used to resolve the backend IP of domain names. Linux, like Windows, has...

Common commands for Linux server systems

Linux is widely used in the field of server operating systems, and the vast majority of Linux...