Change hostname on CentOS/Fedora

<?prettify linenums=true?>

$ 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.

<?prettify linenums=true?>

$ sudo restorecon -v /etc/hostname

This works on CentOS

$ sudo vi /etc/sysconfig/network

HOSTNAME=myserver.domain.com

$ sudo vi /etc/hosts

$ sudo vi /etc/hostname
Written on November 10, 2016