CentOS – Hostname Change


To change host name in CentOS use following steps:

Open /etc/sysconfig/network file

$ vim /etc/sysconfig/network

Now modifiy HOSTNAME= value


my.domain.com is desired host for my machine, similarly we can use other valid domain names.

Next edit /etc/hosts file, here we need to change the host that is associated to your main IPaddress for your server.   my.domain.com my

After completing above two changes restart network by using following command:

$ service network restart 

Now run hostname command:

$ hostname



Above procedure will work both in CentOS 5 and 6 versions.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s