SystemMen - This article, I will show you how to change hostname in CentOS 6. Unlike operating systems that use systemd like CentOS 7 or Ubuntu 16, CentOS 6 will not have the hostnamectl command for you to use. So how do we change the hostname in CentOS 6?
Change the hostname temporarily
In CentOS there is a command that allows you to change the hostname temporarily, which is the
hostname command. This command will change the hostname of the server immediately without reboot. You only need to logout and login again after changing the hostname. Note, after you logout and login again. It may take a while to connect, do not be scared.
But when using the hostname command, the value of the hostname will not be saved when the server reboot (problems can occur such as power failure, hardware failure …).
Change the hostname permanently
To change the hostname permanently, you do the following 3 steps. First, you need to edit the file
Edit the HOSTNAME line with the new hostname you want. Save the file.
Read more: Change the hostname in Ubuntu 16.
Next, edit the
/etc/hosts file and add the line in the image below. With IP is the IP of your server, the new hostname you want. This section is optional, you may not need to do this.
Then, you reboot the server.If you liked this article, then please subscribe to our YouTube Channel for more video tutorials. You can also find us on Twitter and Facebook.
If you appreciate what we share in this blog, you can support us by:
- Stay connected to: Facebook | Twitter | Google Plus | YouTube
- Subscribe email to recieve new posts from us: Sign up now.
- Start your own blog with SSD VPS - Free Let's Encrypt SSL ($2.5/month).
- Become a Supporter - Make a contribution via PayPal.
- Support us by purchasing Ribbon Lite Child theme being using on this website.
We are thankful for your support.