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
3. Open your hosts file, and update the hostname entry and save:
# vim /etc/hosts HOST_NAME

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

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!