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


Step 2 : Set new hostname

sudo hostnamectl set-hostname server-01

Step 3 : Verify the change


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

sudo nano /etc/hosts

Add or modify the line: server-01

Step 5 : Reboot your system

sudo reboot

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