How to change the hostname in CentOS 7

To change the hostname in CentOS 7, you have to do four things:

1. Modify /etc/sysconfig/network

HOSTNAME=hostname.domain.com

2. Modify /etc/hosts

Find:

127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6

Add below that your IP address (a.b.c.d) and the new hostname:

a.b.c.d            hostname.domain.com hostname

3.

Run this command: hostname hostname.domain.com

4. Persist the change using /etc/init.d/network restart

Reference:
https://support.rackspace.com/how-to/centos-hostname-change/

 

Tags

Share this article

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to Top