Sometime we need to change server hostname , It can be possible to change host name by using SSH command line ;

1st we can check the current hostname by command :


outputs example : server1.bipul.me

Now , we change the hostname by editing network and hosts files . we can edit file by using nano or vi command ;

nano /etc/sysconfig/network

look in outputs and find  HOSTNAME value & change with new hostname ;
for example : HOSTNAME=”server2.bipul.me”
Save and close the file.

Now we need to edit hosts file with host name with your IP  :

nano /etc/hosts localhost  server2.bipul.me

Save and close the file.

Set hostname manually without rebooting the box

Type the following command:
# hostname server2.bipul.me

Restart the CentOS networking and other services:

service network restart
/etc/init.d/network restart

Verify new hostnames

Simply type the following commands:
# hostname


thats all.


Jobair Alam Bipul and I’m a 31-year-old tech enthusiast from Bangladesh. have been working in the E-commerce, Domain and Web Hosting industry for more than 10 years

Articles: 67

Leave a Reply

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

Time limit is exhausted. Please reload CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.