How to change the hostname

By | January 21, 2014

One of the basic (yet very useful) operation you can do on a server is to change the hostname. The hostname is basically a label you assign to it so you can identify it more easily.

To change it you need to edit the file /etc/sysconfig/network:

The value from this file is used only on reboot or when you restart the networking deamon.

Next, run the hostname command:


Tip: You can use the hostname command without any parameters to view the current hostname.

Next, you will want to change the values from /etc/hosts: localhost.localdomain localhost

To make sure all the services use the new hostname values you will need to restart the network service:

service network restart

That’s it, folks! Yes, it might seem a bit too much for such a simple change, but hey, you don’t do it every day!

Leave a Reply

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

Time limit is exhausted. Please reload the CAPTCHA.

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