I'm now running CentOS-7.0-1406 and looks like i can't setup hostname properly. As far as i know, you need to setup hostname using hostnamectl set-hostname command and write FQDN in /etc/hosts. I have a centos machine and i want to set it's hostname to "server" and FQDN to "server.mydomain.com". I run hostnamectl command and edit /etc/hosts file:
[root@server ~]# hostnamectl set-hostname server
[root@server ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
{inet_IP_here} server.mydomain.com server
At first everything looks fine, console displays hostname when i run hostname and it displays FQDN when i run hostname -f:
[root@server ~]# hostname
server
[root@server ~]# hostname -f
server.mydomain.com
BUT after i reboot machine and run the same commands again, it starts to display FQDN as hostname:
[root@server ~]# hostname
server.mydomain.com
I must say that it's a VPS server and i have no such problem when i do it on a local virtual machine. Also there is no any settings in VPS control panel which look like hostname. What reason might cause such problems?