This post describe about how to change Hostname in your CentOS 7 or RHEL 7 using commands. Before that we need to understanding hostname,  its divided into three classes are  static, pretty, and transient.
  
Static – The static host name is traditional host which can be chosen by the user and is stored in /etc/hostname file.

Transient – The transient host name is maintained by kernel and can be changed by DHCP and mDNS.

Pretty – It is a free form UTF -8 host name for the presentation to the user.

Another important is a Hostname can be support up to 64 characters in length, Recommend to have FQDN and character consist of a-z, A-Z, 0-9, “-”, “_” and “.” only,

To find out your hostname,

# hostnamectl

# hostnamectl status

Static hostname: localhost.localdomain
         Icon name: computer-vm
           Chassis: vm
        Machine ID: 1224e1b361a9b0e393afcf5d475c5638
           Boot ID: 12347f4abc30a4ff4446yb9823495vv7m
  Operating System: CentOS Linux 7 (Core)
       CPE OS Name: cpe:/o:centos:centos:7
            Kernel: Linux 3.10.0-123.20.1.el7.x86_64
      Architecture: x86_64

or
 
# hostname
localhost.localdomain


Option 1 - Update Hostname:  
 
# sudo hostnamectl set-hostname host.newhostname.com

Check the status:
 
# hostname
host.newhostname.com 
# hostnamectl status --static

# hostnamectl status --transient

# hostnamectl status --pretty

To set permanently execute the below command and don't want to reboot your system.
 
# sudo hostnamectl --static set-hostname host.newhostname.com

Option 2 - Modify Directly :

Directly modify the hostname on /etc/hostname
 
# vim /etc/hostname
host.newhostname.com 


Save that file and execute below command
 
# systemctl restart systemd-hostnamed


Option 3 - Using nmcli:

Change Hostname Using nmcli:

To check your hostname,
 
# nmcli general hostname 

Now, update hostname using nmcli,
 
# nmcli general hostname host.newhostname.com

Restart the hostnamed to force the hostnamectl,
 
# systemctl restart systemd-hostnamed