Change the Hostname

The default hostname for the Raspberry Pi is “raspberrypi”. If you have more than one Raspberry Pi on your network then you may wish to rename them to something more meaningful to avoid confusion. This is easily done by editing 2 files.

First, edit the file /etc/hosts. Edit the last entry highlighted in yellow, where it says “127.0.1.1      raspberrypi” and change raspberrypi to your desired name.

sudo nano /etc/hosts

127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

127.0.1.1 raspberrypi

Ctrl-O to save
Ctrl-X to exit

Second, edit the file /etc/hostname. Change raspberrypi to your desired name, ensuring it is the same name you used above.

sudo nano /etc/hostname

raspberrypi

Ctrl-O to save
Ctrl-X to exit

Next time you reboot, the Raspberry Pi will be advertising its new hostname.

Leave a Reply

Your email address will not be published. Required fields are marked *