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

CERTUM Certificate Brand Information

CERTUM was founded in Poland in 1998 and has developed into a professional certification body in...

Nginx configuration using SSL certificate method

The difference between free certificates and paid certificatesFirstly, free SSL certificates come...

What types of websites are suitable for. ORG domain names ORG domain name suitable for scope sharing

If we are webmasters who built websites in the early days, we should know that COM, NET, and ORG...

Can websites not use SSL certificates? There may be issues with websites not installing SSL certificates

Website security certificate, also known as website SSL certificate. Nowadays, we see many...