HOWTO: Changing the hostname

From Sabayon Wiki
Jump to: navigation, search
i18n: de en tr

How to change the hostname of a computer running Sabayon Linux

In the example below I use the hostname "acertm8215" because I have an Acer TravelMate 8215 laptop, but obviously you can use whatever hostname you want.

During installation of Sabayon Linux you may have accepted the default hostname of "localhost", or you may have specified your own hostname (e.g. "sabayonx86", "neptune" or whatever). In either case, at some point you may want to change the current hostname, and this article explains how to do it.

1. Check the current hostname is properly configured

uname -a
hostname -f
hostname -a
hostname -d

2. Edit /etc/conf.d/hostname


File: /etc/conf.d/hostname


File: /etc/conf.d/hostname

3. Edit /etc/hosts


File: /etc/hosts localhost localhost.localdomain localhost


File: /etc/hosts acertm8215 localhost.localdomain localhost

4. Change the hostname stored in the kernel

To see the current hostname:

sysctl kernel.hostname

To change the current hostname:

sysctl kernel.hostname=acertm8215

5. Change netbios name in /etc/samba/smb.conf (as it defaulted to hostname "localhost")


File: /etc/samba/smb.conf
netbios name = localhost


File: /etc/samba/smb.conf
netbios name = acertm8215

6. Change the hostname in /etc/dhcp/dhclient.conf (otherwise it will still give your old hostname to other nodes on the network to which your PC is connected):

Newer Installs

In a newer install, I've noticed this file is blank. If left blank, editing of this file isn't required. This section assumes that dhclient is the DHCP client running on your PC (Sabayon Linux uses dhclient by default).

However, if you decide to use a different DHCP client (e.g. dhcpcd) then you will have to edit a different file.


File: /etc/dhcp/dhclient.conf
send host-name "localhost";
supersede host-name "localhost";


File: /etc/dhcp/dhclient.conf
send host-name "acertm8215";
supersede host-name "acertm8215";

7. Reboot (or restart networking).

8. Repeat Step 1 to make sure the new hostname is set up correctly.

Article created by Fitzcarraldo on 8 January 2009.