Renaming the hostname of your Raspberry Pi (Raspbian)

One of the first things you want to do if you've just installed Raspbian on your Pi is to change the hostname. You can change your hostname by following these steps.

Steps

You can use the 'hostnamectl set-hostname [name]' command, but that does not update /etc/hosts and causes issues with Docker and other networking services. I prefer to update /etc/hostname and /etc/hosts manually.

1. Change /etc/hostname sudo nano /etc/hostname Change raspberrypi to your desired hostname Hit CTRL+O and then ENTER to Save Hit CTRL+X to Exit note: Only use the letters 'a' to 'z' (upper or lower), digits '0' to '9', and the dash '-' for your new hostname.

2. Change /etc/hosts

sudo nano /etc/hosts Change raspberrypi to your desired hostname Hit CTRL+O and then ENTER to Save Hit CTRL+X to Exit

3. Reboot sudo reboot

  1. Check your new hostname

hostname