How to Change Host Name in Linux Machine

Check Your Linux host name
First, if you want to see the host name, you can use the terminal and then type the following command:
#uname -n
#hostname -a
#hostname -s
#hostname -d
#hostname -f

If the above command you typed correctly then it is definitely no errors then all will probably look fine, but you might want to read to make sure that all settings are correct.

Usually we will assign the host name of the system during the installation process runs.

Changing the hostname running on a Linux system
On Linux systems you can change the hostname with the type command ' hostname '.

no parameters will output now hostname of the system.
#hostname –fqd

will output a complete (qualified domain name or fqdn) from the system.
# hostname NEW_NAME

This will set the host name of the system to NEW_NAME. This immediately active and will remain that way until the system will be rebooted (because this will set the boot system of some special configuration file-see below how to set permanently). You just might need to break out of the shell and then on again in order to see the changes on your shell prompt.

Change the hostname of a permanent system of Debian-based Linux
Debian uses the system file "/etc/" read hostname the host name of the system at boot time and set it up using the init script is "/etc/init. d/" 
#cat /etc/hostname 


So on Debian-based systems we can edit the file "/ etc / hostname" and changed the name of the system and then run.

 The host name that is stored in the file "/ etc / hostname" will be maintained on a system reboot (and will be set to use the same script we use "").

Using sysctl to modify hostname
using sysctl to modify the variable "kernel. hostname":

#sysctl kernel.hostname

to read the current hostname, and

#sysctl kernel.hostname=NEW_HOSTNAME

to change it.

You can use the same process for all debian-based linux distributions and engines as well.

Click here for Comments