Change System Hostname:

CentOS:

To change the hostname, the hostname is located in the following configuration file

/etc/sysconfig/network

The file contains three lines. We are only interested in changing the third linux beginning with hostname as this is the hostname. You can add whatever suits your fancy after the equals symbol.

NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=bob

Then you need to restart the networking process, via the following command

# /etc/rc.d/init.d/network restart

Now you can restart the network services that control the hostname at startup. Manually starting the  above command should show you the results below.

Shutting down interface eth0:                             [  OK  ]
Shutting down loopback interface:                    [  OK  ]
Setting network parameters:                                [  OK  ]
Bringing up loopback interface:                          [  OK  ]
Bringing up interface eth0:                                   [  OK  ]

Now your hostname should be changed. You can check your hostname with the hostname command

# hostname
bob

Ubuntu:

Under ubuntu to change the hostname as of this writing using ubuntu version 10.04.03 you need to modify the following file

/etc/hostname

There will be one line with the name of the machine. Just change the name from what exists to the new name you want the machine to be called. There is a issue I have with ubuntu 10.04.03. It seems that the init script to restart the hostname does not work, nor the hostname service. The only way I have been able to get around this is to reboot the machine. This may be fixed in versions afterwards.

3 thoughts on “Change System Hostname:”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.