I’m running some centos7 droplets. I’ve followed other posts saying to update hosts and hostname to change the hostname of the droplet and that works fine. A reboot to two later however and the hostname file has reverted back to its original content. How do I stop that from happening?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Are you running NetworkManager? Here are a few more places to check if you haven’t already:
hostnamectl set-hostname your.host.name
/etc/sysconfig/network # set variable HOSTNAME="your.host.name"
/etc/hostname
Cheers
To change the hostname and preserve changes after a reboot you have to do two things:
1- Change the hostname in /etc/hostname file.
2- Execute this command: hostname <new_host_name> replace <new_host_name> with your desired hostname also you need to update /etc/hosts with an entry for the new hostname and your droplet’s IP address.
Hope this helps.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.