Permanent hostname change on RedHat based systems

Permanent hostname change on RedHat based systems

1. Modify host name in /etc/sysconfig/network
2. after step 1 , restart network service using below command
service network restart
3. Modify /etc/hosts file
4. Change the hostname on a running Linux system
On any Linux system you can change its hostname with the command ‘hostname‘.
hostname
without any parameter it will output the current hostname of the system
it will output the fully qualified domain name (or FQDN) of the system.
hostname –fqd

hostname NEW_NAME
will set the hostname of the system to NEW_NAME. This is active right away and will remain like that until the system will be rebooted (because at system boot it will set this from some particular file configurations — see bellow how to set this permanently). You will most probably need to exit the current shell in order to see the change in your shell prompt.

5 . Modify /etc/hosts to have new hostname

6. use sysctl to change the variable kernel.hostname:
sysctl kernel.hostname=new_hostname
#sysctl kernel.hostname=NEW_HOSTNAME

7. Modify /etc/hostname with new hostname

8. restart reboot the machine to make and verify changes done are permanently

NOTE: you can reboot at later stage also if you dont want to reboot immediately ,because reboot will help you to verify that changes done are proper
however if you are already in middle of something and cannot reboot machine , so you can just exucte comamnd “hostname ” and see current hostname of machine and it should be new hostname

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

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

%d bloggers like this: