Changing the Hostname

From DSL Wiki

   This page in other languages: EspaƱol

Contents

Requirements

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

  • You will need root access to make the required changes
  • You need to know how to use a text editor
  • You need to know how to use a file manager (Emelfm)
  • You'll probably have to use the command line (terminal/bash)

What to do

Open the following files in your favorite text editor:

/etc/hostname

Change box to your new hostname. Save the file.

/etc/hosts

On the very first line, you should see:

       127.0.0.1        box localhost

Change box to your new hostname. Save the file.

/etc/mailname

Change box to 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:

       hostname box

Change box to your new hostname. Save the file.

Cheat Code

You may have to change a boot line cheat code (host=). Add the following cheat code in your boot loader config file:

       host=newname

Where newname is your new hostname.

Read cheat codes if you need help doing this for your boot loader (LILO/GRUB).

For LILO, follow these steps:

1. Edit the file /etc/lilo.conf. Scroll down to line 99, and find the line append=. Add:

       host=newname

For example, you might end up with a long list of boot arguments, like:

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

2. Save the file (/etc/lilo.conf)

3. Install the new configuration to the MBR with the following command.

       sudo lilo -C /etc/lilo.conf

Reboot

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