This article shows step-by-step how to to change hostname on CentOS 6.6 from the default name localhost.localdomain to server.linglom.localdomain as example.
Step-by-step to change hostname on CentOS 6.6
- On CentOS 6.6, type the command below to see the current hostname. The default name is localhost.localdomain.
- Edit /etc/sysconfig/network by type the command below.
- Modify HOSTNAME to the value that you want.
Note: To modify file with vi editor, press i to enter edit mode and make changes as you want. Once finish editing, press ESC + : (colon) and type wq to quit vi editor and save changes to the file.
- Next, edit /etc/hosts by type the command below.
- Add a new line with IP address as 127.0.0.1 for the new hostname.
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 127.0.0.1 server.linglom.localdomain
- Save the file and reboot the system by type:
shutdown -r now
- After reboot, hostname is now changed to new value.