Changing the server hostname permanently

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

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

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 – 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.

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

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

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


One thought on “Changing the server hostname permanently”

Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s