Change CentOS / RHEL 7 server hostname

Change your hostname without restarting the server with these three easy steps:

1.-Delete the old name and set a new name.

    sudo nano /etc/hostname

Ej. 192.681.1.8     midominio.com

2.- Add your hostname or replace the old one.

    sudo nano /etc /hosts

midominio.com

3.-Add the following line:

     hostname cambiequiporelnombredehostnuevo

With this last step you will not need to restart the server.