Changing the server hostname permanently

Yes, Changing the Server hostname. How to do it?

Is it by using hostname command?
sms@test ~]# hostname server.hostname.com

Do you think this will change the hostname permanently? Actually it won’t. By the next reboot you will see the hostname change has been reverted. Then how will you change the Hostname? If you are having any control panel you can do it from User Interface. What if you are not able to access the Control Panel of the server? Here are the Methods to change the Server hostname permanently from Command Line itself . ***************************************************************************************
For Debian based systems
Need to edit /etc/hosts and /etc/hostname files.
In /etc/hostname simply overwrite the existing hostname with a new one. In /etc/hosts you will find the hostname on the line beginning 127.0.0.1 – overwrite only the hostname with the new one, and then reboot.

For RedHat Based Systems
You can achieve it by editing the file “/etc/sysconfig/network“. You need to Edit hostname variable in that file.
~~~~
HOSTNAME=test.server.com
~~~~

Another way to change it in Redhat Systems is by using “sysctl” command.
sysctl kernel.hostname                                        =======> Shows the Hostname
sysctl kernel.hostname= test.server.com   =======>  Changes the Hostname

Please don’t forget to reboot the server after doing these changes.
***************************************************************************************

Hope it is useful. Have a Great Day !!!!

Advertisements

One thought on “Changing the server hostname permanently”

Leave a Reply

Please log in using one of these methods to post your comment:

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