Change hostname on CentOS/Fedora

$ sudo hostnamectl set-hostname --static "YOUR-HOSTNAME-HERE"

If the hostname cannot be saved on Fedora after reboot, using the following command to fix it.

$ sudo restorecon -v /etc/hostname

This works on CentOS

$ sudo vi /etc/sysconfig/network

$ sudo vi /etc/hosts

$ sudo vi /etc/hostname

Leave a Reply

Your email address will not be published. Required fields are marked *