Thursday, June 21, 2012

UBUNTU: How to change hostname in new clone server?

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.

#hostname --fqd

it will output the fully qualified domain name (or FQDN) of the system.


#hostname NEW_NAME

it 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).
Permanent hostname change on  Linux systems
#sudo nano  /etc/hostname
We can edit the file /etc/hostname and change the name of the system and then run:
/etc/init.d/hostname.sh start
The hostname saved in this file (/etc/hostname) will be preserved on system reboot.
Reboot the server to see the changes.

OR


Use sysctl to change the hostname
Use sysctl to change the variable kernel.hostname:
#sysctl kernel.hostname
to read the current hostname, and
#sysctl kernel.hostname=NEW_HOSTNAME
to change it.
If you want more details check sysctl man page
 ..

0 comments:

Post a Comment