CentOS 7 how to change hostname

After I’ve created my home server I’ve tried to change it’s host name by going to /etc/sysconfig/network. For my surprise it was empty. Then I’ve recalled that in version 7 CentOS started using systemd. Hence the location changed.
New place to edit is /etc/hostname

The inconvenience of editing file directly is that system reboot is required to apply the change.

Alternative method is to use Network Manager tool by invoking nmtui.

Network Manager TUI
Change hostname via Network Manager TUI

and then execute:
systemctl restart systemd-hostnamed

You can type hostname to validate the change.

If you have found a spelling error, please, notify us by selecting that text and pressing Ctrl+Enter.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.