Filed under Web Hosting

Normally we will set the hostname of a system during the installation process. Many people don’t care about this, and don’t change the hostname even if for example this was set to some random name by the datacenter that installed the system (most likely they will set this to “debian” on any debian installation, etc). For me, it is important to see on each one of the ssh screens I will have open at any time a different hostname that is relevant and will give me quickly the information on what system I am logged in.

On any Linux system, you can change its hostname with command hostname (duh). It’s easy as :

hostname NEWNAME

The problem is that it will be resetted at next reboot by some configuration file. To make the change permanent on a Red Hat / CentOS system, simply edit the /etc/sysconfig/network file :

/etc/sysconfig/network
NETWORKING=yes
HOSTNAME=”plain.domainname.com”
GATEWAY=”192.168.0.1″GATEWAYDEV=”eth0″
FORWARD_IPV4=”yes”

You can also use sysctl to change the variable kernel.hostname :

sysctl kernel.hostname=NEWHOSTNAME

On a Debian based system, edit the file /etc/hostname and change the name of the system. When done, run :

/etc/init.d/hostname.sh

Related Posts

Posted by Stephane on Monday, August 27th, 2007


You can follow any responses to this entry through the magic of "RSS 2.0" and leave a trackback from your own site.

Post A Comment