Thursday, November 4, 2010

Change your Hostname without Rebooting in RedHat Linux

This aticle covers how to change your hostname in RedHat Linux without rebooting.

Steps:
1- Log in to Linux as root and go to /etc/sysconfig directory and open the network file with any text editor
# cd /etc/sysconfig
# vi network

2- Look for the HOSTNAME line in the file and replace the old hostname with the new one you want to use and save the file.

3- Next we go and edit the /etc/hosts file and replace the old hostname with the new one you want to use and save the file.
# vi /etc/hosts

4- Use the hostname command to change the hostname that is currently set.
# hostname rac2

5- Finally we will restart the network service to apply the changes we made to /etc/hosts and /etc/sysconfig/network files.
# service network restart

6- To verify the hostname has been fully changed, open a new terminal session and you will find that the hostname has been changed or logout of your system and you should see your new hostname being used at the login prompt and after you've logged back in.

No comments: