How to change hostname on Linux CentOS

change Linux server hostname using SSH

1. By default, all servers already set the hostname, if you need to change server hostname, you need to edit the /etc/sysconfig/network file. please following the command:

 # nano /etc/sysconfig/network

2. you need to choose and change the HOSTNAME=value flowing the command line:

 HOSTNAME=yourserver.yourdomain.com

3. next step, edit the /etc/hosts flowing the command line

 nano /etc/hosts

4. now edit the etc hosts the command line, “hostname.your-domain.com” eadit and set your new hostname here and save.

127.0.0.1      localhost localhost.localdomain

187.32.90.25   hostname.your-domain.com   hostname

 ~


 ~


 ~


 ~

-- INSERT --                 2,43-57    ALL

5. now run the command hostname and see output:

[root@server ~]# hostname

your-new-hostname.your.domain.com

[root@server ~]#

6. now you need restart you server networking flowing the command line:

# /etc/init.d/network restart

now successfully change your server FDQN hostname.

LEAVE A COMMENT