How to change hostname and fqdn.

SOURCE : your Linux hostname
First, see if your host name is set correclty using the following commands:
#uname -n
#hostname -a
#hostname -s
#hostname -d
#hostname -f

If the above commands return correctly with no errors then all may be well; however, you may want to read on to verify that all settings are correct.
Normally we will set the hostname of a system during the installation process.


Change the hostname on a running Linux System
On any Linux system you can change its hostname with the command ‘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
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.

Permanent hostname change on Debian based Linux systems
Debian based systems use the file /etc/hostname to read the hostname of the system at boot time and set it up using the init script /etc/init.d/
#cat /etc/hostname
So on a Debian based system we can edit the file /etc/hostname and change the name of the system and then run
/etc/init.d/ startto make the change active. The hostname saved in this file (/etc/hostname) will be preserved on system reboot (and will be set using the same script we used
If you want more details check hostname man page

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
You can use the same process for all debian based distributions and other linux machines


~ di diegotech su marzo 16, 2008.


Inserisci i tuoi dati qui sotto o clicca su un'icona per effettuare l'accesso:


Stai commentando usando il tuo account Chiudi sessione /  Modifica )

Google+ photo

Stai commentando usando il tuo account Google+. Chiudi sessione /  Modifica )

Foto Twitter

Stai commentando usando il tuo account Twitter. Chiudi sessione /  Modifica )

Foto di Facebook

Stai commentando usando il tuo account Facebook. Chiudi sessione /  Modifica )


Connessione a %s...

%d blogger hanno fatto clic su Mi Piace per questo: