Click here for a free subscription to "HDE" our site newsletter.
Email:

Raspberry Pi Beginner Projects: Give your Pi a name

Changing the name of your Pi

The defaults name or "hostname" of your Raspberry Pi running Raspian is "raspberrypi". This is OK and on the next page I show you how to set up a SAMBA server which will make your Pi visible on your network. You will be able to identify the device by it's name.

This is great provided that you only every plan to have one Raspberry Pi on your network. If you put more than one on the network without changing the hostname then you will only be able to see one of them and I'm not sure which one it will be.

So to avoid this potential problem I will show you how to change the hostname of your Pi so that you can avoid any confusion later.

The first problem you are going to have is deciding on a name to give your Pi. In the past I have spent hours trying to think of catchy names to give machines. Names that I can remember and that are unique on my network. I can't choose one that I've already used because that would confuse me even if I no longer use the old machine that had the name.

What I and others that I know do is think of a theme. Some people choose names of snakes or breeds of dogs or even countries. I personaly use the theme "female super heroes" which has served me well so far. My first Raspberry Pi has just been named "Raptor". This isn't one of the better known super heroes I know but I have used up most of the good ones. I had to resort to a list on Wikipedia this time.

So pick a fun theme and then decide on a name that fits with the theme for your Pi. I will use the name "raptor" as the new hostname in the following examples.

The hosts file

First we edit the hosts file to make sure that your Pi knows it's network name when typed at a Pi terminal:

pi@192.168.0.25~ $ cd /etc
pi@192.168.0.25 /etc $ sudo nano hosts

Change the line:
127.0.1.1 raspberrypi
To:
127.0.1.1 raptor

Then save the file:
^O
And exit the editor:
^X

pi@raptor /etc $

The hostname file

The "hostname" file is also in the /etc directory and contains nothing but the hostname string. Use the nano editor again to change the contents from "raspberrypi" to "raptor". Or whatever name you want to give your Pi.

pi@raptor /etc $ sudo nano hostname

When you have changed the hostname file you must commit the change for it to take effect:

pi@raptor /etc $ sudo /etc/init.d/hostname.sh

Notice that you must supply the full path to the hostname.sh file.

For all these changes to take effect you should reboot your Pi now:

pi@raptor /etc $ sudo reboot

On the next page I show you how to make your Pi's file system visible on your network.



Now subscribe to our newsletter and don't miss a thing
 



Comments

No comments yet.

Add Comment

* Required information
(will not be published)
 
Bold Italic Underline Strike Superscript Subscript Code PHP Code Quote Insert line Bullet list Numeric list Link Email Image Video
 
Smile Sad Huh Laugh Mad Tongue Crying Grin Wink Scared Cool Sleep Blush Unsure Shocked
Captcha
Refresh
 
Enter code:
 
Notify me of new comments via email.
 
Remember my form details on this computer.
 
I have read and understand the privacy policy. *
 
I have read and agree to the terms and conditions. *
 
Click here for a free subscription to "HDE" our site newsletter.