To change hostname permanently in CentOS, use the following hostnamectl command (not hostname).