Changing the Hostname of your Raspberry Pi | CPD for teachers

Changing the Hostname of your Raspberry Pi

This guide will show you how to change the hostname of your Raspberry Pi. This assumes that you are already SSHed into your Raspberry Pi. If you are not, see the following: http://www.cpdforteachers.com/resources/sshing-into-your-raspberry-pi/. The hostname identifies your device on the network. Note that this is an operating system option and will persist with the SD card. This means that if you swap the SD cards in two Raspberry Pis, their hostnames will also swap. Furthermore, if you rewrite the SD card the hostname will revert to its default value.

 

Caveats: While following this guide will change your hostname, depending on your network , you may not be able to detect this change from other computers. This is a problem especially prevalent on Windows machines. If you have problems detecting the change, try using a different Network Interface Card (eg: use your wired card instead of your wireless card or vice versa).

 

1) Enter the command following command:

sudo nano /etc/hostname

2013-07-09_130641

2013-07-09_131016

 

2) Edit the hostname as desired using the keyboard

2013-07-09_134222

 

3) Press Ctrl-O to save and then press the return key to accept the name and overwrite the existing file.

2013-07-09_134337

 

4) Press Ctrl-X to leave the editor and return to the command line

2013-07-09_131949

 

5) Enter the following command

sudo nano /etc/hosts

2013-07-21_115426

2013-07-21_114619

 

6) Change the value for the entry 127.0.1.1 to your desired hostname. It must be identical to the one you used for the instruction above 2013-07-21_115016

 

7) Again, press Ctrl-O to save and then press the return key to accept the name and overwrite the existing file.

2013-07-21_115016

 

8) Press Ctrl-X to leave the editor and return to the command line

2013-07-21_115519

 

9) Now make the change active by running the following command

sudo /etc/init.d/hostname.sh start
2013-07-21_115635

 

comments powered by Disqus