How To Change A Hostname In Linux – RHEL / CentOS 7 & 8

In this article, you will learn the step by step process of how to change a hostname in Linux (Red Hat /CentOS 7 and 8) by editing “/etc/hostname” file.

Steb By Step Process Of How To Change A Hostname In Linux (RHEL /CentOS 7 & 8)

Take the following steps to rename a hostname

1. open the “/etc/hostname file”

[root@HQDEV1 ~]# vi /etc/hostname

2. Edit the file to your desired hostname. In my case, I want to change the hostname to “tekneed”

tekneed

3. restart the systemd.hostnamed service

[root@HQDEV1 ~]# systemctl restart systemd-hostnamed.service

4. Verify

[root@HQDEV1 ~]# hostname
tekneed

NB: If you are logged in via SSH, you may need to open another SSH session to see the hostname reflected

change a hostname in Linux

Your feedback is welcomed. If you love others, you will share with others

Be the first to comment

Leave a Reply

Your email address will not be published.


*