RHEL / Centos Linux 7: Change and Set Hostname Command

‮tth‬ps://www.lautturi.com
RHEL / Centos Linux 7: Change and Set Hostname Command

To change the hostname of a Red Hat Enterprise Linux (RHEL) or CentOS Linux 7 system, you can use the hostnamectl command.

Here are the steps to change the hostname of a RHEL or CentOS Linux 7 system:

  1. Use the hostnamectl set-hostname command to set the new hostname. For example:
sudo hostnamectl set-hostname newhostname

This will set the new hostname for the system.

  1. Edit the /etc/hosts file and update the localhost entry with the new hostname. For example:
127.0.0.1   localhost newhostname

This will ensure that the new hostname is resolved correctly on the system.

  1. Restart the network service to apply the changes:
sudo systemctl restart network

The hostname of the system will now be changed to the new hostname.

It's always a good idea to carefully review the documentation and use the appropriate commands to change the hostname of a RHEL or CentOS Linux system. This will help ensure that the hostname is set correctly and that the system is properly configured.

Created Time:2017-10-30 14:27:13  Author:lautturi