In Centos/rhel 7, there is a command-line tool called Hostnamectl, which allows you to view or modify the configuration associated with a host name.
To view the host name-related settings:
$ HOSTNAMECTL Status
View only static, transient, or flexible hostname, using "--static", "--transient" or "--pretty" options, respectively.
$ hostnamectl Status [--static|--transient|--pretty]
To modify all three host names at the same time: static, transient, and flexible hostname: change to www
$ sudo hostnamectl set-hostname "www"
Set the/etc/hosts to save the changes, or the restart will fail.
If you only want to modify a specific hostname (static, transient or flexible), you can use the "--static", "--transient" or "--pretty" option.
For example, to permanently modify a host name, you can modify the static hostname:
You do not have to restart the machine to activate the permanent hostname modification. This command modifies the kernel host name immediately.
$ sudo hostnamectl--static set-hostname
CENTOS 7.0 Change hostname