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 13KzxfEoFPzt5ccoQvSkUEytTgQV8JN5ej
Donate
Share This Post

About Author: Curtis K

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