Tuesday, January 22, 2013

How to change the Hostname RHEL linux ?

Hi Friends,

It is easy to change the hostname on Linux. We can do the same with following commands and edit of the files.

1. #hostname "desired hostname"

hostname is the command which we need to run from # prompt or with sudo access. by doing this you will only be able to see the change for the current session on which you re logged in. As you exit from the system or session. the hostname again will be the same, which it was.

2. The second step is to change the hostname by editing below file :-

vi /etc/sysconfig/network or networking file which will be having entry of HOSTNAME= .............. just type the desired hostname, save it and come out.

3. the 3rd step is to change the hostname in /etc/hosts file, but before editing any file, please ensure backup of the files using "cp -rp" command. and the edit any file.

in /etc/hosts file edit the name which is given infront of the IP, and loop back address.

4. The 4th step is to run the

#service network restart

this command will make the change permanent. now relogin in to the server and check the hostname  should be changed to new one.

Best Regards & amp; love sharing
Amit Chopra


No comments: