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


Question.png
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
hostname -f
hostname -a
hostname -d


2. Edit /etc/conf.d/hostname

Change:

File: /etc/conf.d/hostname
HOSTNAME="localhost"

to:

File: /etc/conf.d/hostname
HOSTNAME="acertm8215"


3. Edit /etc/hosts

Change:

File: /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost

to:

File: /etc/hosts
127.0.0.1 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")

Change:

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

to:

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):

Question.png
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.

Change:

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

to:

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.