Changing the Hostname

From DSL Wiki

   This page in other languages: EspaƱol

So you like to name your computers, and you would rather see 'meanmachine' than 'box' at a command prompt?


  • Please note that you will need root access to make the required changes.


Open the following files in your favorite text editor:


/etc/hostname

Change box for your new hostname. Save the file.


/etc/hosts

On the very first line, you should see:

127.0.0.1 box localhost

Change 'box' for your new hostname. Save the file.


/etc/mailname

Change box for your new hostname. Save the file.


/etc/init.d/knoppix-autoconfig

Scroll down to line 363, or line 328 on more recent versions. It should look like this:

hostname box

Change box for your new hostname. Save the file.


Cheat Code

There is a cheat code (host=) that needs to be added or changed, also. Add the following host= cheat code in the appropriate boot loader config file.

host=newname

Where newname is your new hostname. See cheat codes for how to do this for your boot loader (lilo/grub).

For lilo, edit

/etc/lilo.conf

Scroll down to line 99, and add host=newname to the append= line.

append="hda=scsi hdb=scsi hdc=scsi hdd=scsi hde=scsi hdf=scsi hdg=scsi hdh=s csi apm=power-off nomce noapic host=meanmachine"

Continuing with the lilo example, save the file, and install it to the MBR with the following command.

sudo lilo -C /etc/lilo.conf

Reboot your computer; your system will now have the Hostname you wanted.