Search This Blog

Monday, February 22, 2010

Set the Hostname in Linux system


The hostname is the name by which your Linux instance "knows itself." By convention the hostname correlates to a machine-specific domain name pointed to your server. Some applications require that your hostname is set before they will function properly.

To see what your hostname is currently set to, issue the following command:

hostname

To set the hostname, we recommend creating an /etc/hostname file that contains the hostname of the current machine. You can accomplish this with the following command:

echo "lollipop" > /etc/hostname

In this example, "lollipop" is the desired hostname of the machine. Now, issue the following command to set the hostname:

hostname -F /etc/hostname

Some distributions, notably Arch Linux, set the hostname by specifying it in the /etc/rc.conf file. If this is the case for your system, set the hostname by editing the "HOSTNAME=" line so that it reads:

HOSTNAME="lollipop"

The hostname will be set the next time your system boots.


No comments: