Logo

How to Set or Change Hostname on CentOS 7

Apr 01, 2024

To change hostname on CentOS 7, follow these steps:

Step 1 : Check current hostname

hostname

Step 2 : Set new hostname

sudo hostnamectl set-hostname server-01

Step 3 : Verify the change

hostname

Step 4 : Update /etc/hosts with the new hostname

sudo nano /etc/hosts

Add or modify the line:

127.0.0.1 server-01

Step 5 : Reboot your system

sudo reboot

Congratulations! You have successfully set or changed the hostname on CentOS 7.