Technology and troubleshooting.

Tuesday, February 9, 2016

How to change hostname in CentOS linux

This tutorial describes how to change a server hostname in CentOS Linux.

Procedure to change hostname in CentOS Linux

Open the terminal or login over the ssh session. You must login as as the root user to change hostname in centos

[root@Techlanda ~]# vi /etc/sysconfig/network

vi /etc/sysconfig/network





At line 2 replace your hostname
 HOSTNAME=yourhostname

Change hostname name






Press ESC key and then give :wq! to save :q! for Abort changes

Restart networking on your server to ensure that changes will persist on restart.  
[root@Techlanda ~]# /etc/init.d/network restart

Restart in command line 

[root@Techlanda ~]# init 6

Output

[root@Techlanda ~]# hostname

hostname






I hope this information is useful for you. Please forgive any typos or incomplete sentences.

Share: