How to change the hostname of a Linux system |
|
|
How to change the hostname of a Linux system Normally we will set the hostname of a system during the installation process. But we can change the hostname of the server in the following ways. Change the hostname on a running system For Linux systems you can change its hostname with the command ‘hostname'. $hostname The command 'hostname' without any parameter will output the current hostname of the system. $hostname --fqd The 'hostname' command with the above mentioned arguments will output the fully qualified domain name. $hostname new_server This will reassign the current hostname of the server as 'new_server'. This hostname will remain in the server until the next reboot. Permanent hostname change For Redhat based distros: RedHat based system use the file /etc/sysconfig/network to read the hostname at time of system boot up. This is set using the init script /etc/rc.d/rc.sysinit So edit this file and give the required name for the HOSTNAME variable in order to preserve the hostname at startup. Please make sure that the hostname which we have entered should be a fully qualified domain name (FQDN). For Debian based distros: Debian based systems use the file /etc/hostname to read the hostname of the system at boot up time. The init script used here is /etc/init.d/hostname.sh Edit the file /etc/hostname and change the name of the system and then run the script /etc/init.d/hostname.sh start This will make the change active and will preserve even in system reboot. |
|
Powered by
Deru Communications (Webhosting Knowledgebase)