What Is the Command to Change Hostname in Linux?
Contents to Change the Hostname Invoke the Hostnamectl Command with the Set-Hostname Argument Followed by the New Hostname. Only the Root or a User with Sudo...
To change the hostname invoke the hostnamectl command with the set-hostname argument followed by the new hostname. Only the root or a user with sudo privileges can change the system hostname.
Can we change hostname?
Device or system hostnames are used to easily recognize a machine within a network in a human readable format. It is not much of a surprise, but on Linux system, the hostname can be easily changed by using simple command as “hostname“. … There is another way to change the hostname of your system – permanently.
Must Read
How do I change the hostname in Linux 6?
Make sure you are logged in as root and move to /etc/sysconfig and open the network file in vi. Look for the HOSTNAME line and replace it with the new hostname you want to use. In this example I want to replace localhost with redhat9. When you are done, save your changes and exit vi.