Change Raspberry Pi’s hostname

By default, the Raspberry Pi hostname is raspberrypi. This hostname will be visible on the network. If you have two or more Raspberry Pi devices, you might want to change the default hostname so you can differentiate between devices and prevent name conflicts. This can be done by choosing the Hostname option under Advanced Options in raspi-config:

hostname raspi config

Read the notice and click Ok:

hostname notice raspi config

Enter the new hostname. The hostname should contain only letters, numbers, and the hyphen (-):

change hostname raspbian raspi config

Reboot your device. The device should have the new hostname after the reboot.

Another way you can change your hostname is by using the terminal. Launch the terminal (third icon on the right of the Menu bar) and enter the sudo nano /etc/hostname command. This will open up the hostname file in the nano text editor. Type the new hostname in nano, save the changes (Ctrl+o) and exit (Ctrl+x) :

raspbian change hostname nano

Now, open the /etc/hosts file in nano using the sudo nano /etc/hosts command. Change all occurances of the old hostname with the new hostname:

raspbian change etc hosts nano

Reboot your Raspberry Pi. The device should have the new hostname after the reboot.

Geek University 2021