In order to change your system’s hostname if you are running Centos 7, follow these steps:
- Update the following file /etc/sysconfig/network by replacing or adding the variable HOSTNAME with the following format:
HOSTNAME=your.hostname.com
- After that, ensure your main server IP address (see it with hostname -i) is pointing to the new hostname by updating or replacing if needed, inside the file /etc/hosts, so you should leave it as the following example (assuming you are running with the IP address 192.168.50.20):
192.168.50.20 ...
APR