HOSTNAME resets after reboot... why?

1) Create a new linode (Centos 7).
2) login to the console as root (using Weblish).
3) set hostname using "hostname "my.host.com" (not actual name)
4) reboot
5) login to the console as root (using Weblish).
6) get hostname using "hostname"
7) hostname is no longer "my.host.com", it is the original hostname assigned by linode.

Why does this happen?

2 Replies

On CentOS7, changes to your hostname with the hostname command won't persist upon reboot. Instead, use the following command (per our Getting Started Guide):

hostnamectl set-hostname my.host.com

Your hostname will now remain after reboots.

I would have never known this by searching the internet for why. I was later told to edit the /etc/hostname file with nano and change it there which I did. This also solved the mysterious changing hostname issue.

It's more acceptable to me to use the command line so I'll adopt that in the future.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct