This short tutorial will guide you through renaming your CentOS 6 server. Like many settings in the Linux world, you can make the change temporary or persistent. I show you both ways and explain why you would even consider a temporary change.
You can temporarily change the name of your server using the hostname command. You might be wondering why someone would do this. One reason for doing this is a persistent hostname change requires a reboot. You may want to hold off on rebooting until other tasks are completed, however, some tasks require the hostname to be set. This approach allows you to do that.
- Run the hostname command with the fully qualified host name you want the server to have.
In order for our hostname change to survive a reboot, we need to make the configuration persistent. We do this by setting the host name in our global network configuration file. Without defining it there, our hostname will be reset the next time our server boots.
- Open the global network configuration file into a text editor.
- Find the HOSTNAME setting. It’s default value will depend on your environment.
- Replace the HOSTNAME value with the server’s chosen fully qualified domain name.
- Save your changes and exit the text editor.
- To apply the hostname changes immediately, reboot the server.