Change hostname in CentOS

The configured hostname is contained in a file;

/etc/sysconfig/network

Use vi to modify the last line and replace it with the desired fully qualified domain name (FQDN).

To save changes in vi, press ESC, then type

:wq!

to write the file and quit vi.

Reboot your server.