How to change hostname on CentOS Linux

This quick tutorial will describe how to change the hostname on your CentOS Linux server.

Where HOST_NAME occurs, replace it with your desired hostname.

1. Run the hostname command:
hostname HOST_NAME
2. Open /etc/sysconfig/network, update the HOSTNAME line and save:
# vim /etc/sysconfig/network
HOSTNAME=HOST_NAME
3. Open your hosts file, and update the hostname entry and save:
# vim /etc/hosts
127.0.0.1 HOST_NAME

Alternatively, you can use this script to update your hostname.

Scan to Donate Bitcoin
Like this? Donate Bitcoin to at:
Bitcoin 14M4a7UHEX61VoHkyjj4dxbUBNGGz3hmhM
Donate
Share This Post

About Author: Curtis K

Hi! My name is Curtis, and I am the creator of CentOS Blog. Please feel free to comment any suggestions, feedback or questions on my posts!