I found different ways to define the hostname …
what is the correct way?
In the case of RHEL 5 and 6 the former way is recommended. I don’t know whether that advice has changed with RHEL 7.
hostnamectl set-hostname whateveryourhostnameshouldbe
That depends on what release you’re using. On CentOS 7, you’d use the
“hostnamectl” command. The sysconfig/network file is no longer used for that purpose.
Otherwise, consult /usr/share/doc/initscripts/sysconfig.txt