Tutorials

Changing Your Raspberry Pi Hostname

Overview

The default hostname for the Raspberry Pi  in Raspbian is raspberrypi and in RaspBMC is raspbmc. This is percfectly ok if you only have one device of each. But when you start adding other Raspberry Pi to the family this can become a problem.

In this tutorial, you'll learn how to change the hostname of the Raspberry Pi in both Raspbian and Rapbmc. It might also work with other distributions if they are Debian based.

Step 1

If your Pi is connected to a monitor and has a keyboard, you can connect to the Pi console. Otherwise you can SSH your PI.

Step 2

You'll have to change the name of your Pi in two different files: /etc/hosts and /etc/localhost

To do so:

nano /etc/hosts

You'll see something like:

127.0.0.1       localhost
::1             localhost ip6-localhost ip6-loopback
fe00::0         ip6-localnet
ff00::0         ip6-mcastprefix
ff02::1         ip6-allnodes
ff02::2         ip6-allrouters

127.0.0.1       raspberrypi

Leave all of the entries alone except the ones with the hostname raspberrypi. Replace raspberrypi with whatever hostname you desire. For example you can replace it with loungeroompi
Press CTRL+X to close the editor; agree to overwrite the existing file and save it.

At the end I'll look like this:

127.0.0.1       localhost
::1             localhost ip6-localhost ip6-loopback
fe00::0         ip6-localnet
ff00::0         ip6-mcastprefix
ff02::1         ip6-allnodes
ff02::2         ip6-allrouters

127.0.0.1       loungeroompi

Open your second file:

sudo nano /etc/hostname

You'll see something like this:

raspberrypi

Replace raspberrypi with the same name you used in the previous file: loungeroompi
Press CTRL+X to close the editor; agree to overwrite the existing file and save it.

At the end I'll look like this:

longeroompi

Step 3

Commit the changes and reboot the system.

To commit the changes type in:

sudo /etc/init.d/hostname.sh

Then reboot your system:

sudo reboot

If all went ok, your Pi should have a different name now.

 

 

Comments

There are no comments yet, be the first one to write a comment.
Add comment

* - required field

*




CAPTCHA image for SPAM prevention If you can't read the word, click here.

*
*
Continue Shoppping View Cart
Continue Shoppping View Wishlist