In this Raspberry Pi guide, we will be showing you how to change your hostname.
A hostname is a human-readable label that your Raspberry Pi will give out when another network device queries it.
The hostname is a way of labeling different devices without you having to remember the IP address or mac address of each device.
With this guide, we will be showing you how to retrieve your current hostname as well as how to change it.
Knowing how to change the hostname for your Raspberry Pi is essential, especially when you have multiple Pi’s connected to the same network.
Having different hostnames will help you differentiate between each Raspberry Pi.
Here is a list of the equipment we recommend for this guide on changing your Raspberry Pi’s hostname.
Raspberry Pi 1, 2, 3 or 4
Checking the hostname of your Raspberry Pi
Our first task is to check what the current hostname of our device is. Luckily for us, this is a very straightforward task and requires us to run a single command.
1. All you need to do is run the following command in the terminal of your Raspberrry Pi to retrieve it’s hostname.
2. From this command, you should end up seeing a result showing the hostname of your device.
Changing the hostname of your Raspberry Pi using the terminal
In this section, we will be walking you through the straightforward steps of changing the hostname of your device within the terminal.
To be able to change the hostname of your device, you will need to be using a user that has superuser access.
1. Luckily for us, modifying the hostname for your Raspberry Pi is a relatively easy task.
To start, we need to modify a file called
hostname that resides in the
Begin modifying this file by running the following command within the terminal of your Pi.
sudo nano /etc/hostname
2. To change your hostname, all you need to do is swap out the one in this file.
For example, let’s say that we wanted to change our hostname to
To do this, we would change the file, so it looks like the following.
3. Once you are happy with the hostname, please save the file by pressing CTRL + X, then Y, followed by ENTER.
4. Next, we need to modify the
/etc/hosts file as the hostname is referenced within there too.
Modify the file by using the command below.
sudo nano /etc/hosts
5. Within this file, find the following line and replace the hostname with your own.
For our example, we will be using the hostname
6. Once you have finished making the necessary changes, please save the file by pressing CTRL + X, then Y, followed by ENTER.
7. For other devices to start seeing the new hostname of our Raspberry Pi, we will need to go ahead and restart it.
We can restart the Pi by using the following command.
Using raspi-config to change the hostname
In this section, we will be showing you how to use the raspi-config tool to change the hostname on your Raspberry Pi.
Using this tool is slightly faster and easier than using the terminal.
1. To start, we will need to load the raspi-config tool by using the command below.
2. The option to change the hostname is located within the “Network Options” page.
Select this option by using the arrow keys and ENTER.
3. Now select “N1 Hostname” and press ENTER.
4. The next message will explain the characters that you can use for a hostname.
Once you have read through this message, press ENTER to proceed.
5. Finally, you can enter the hostname that you want to give to your Raspberry Pi.
For this example, we are just using the hostname “pimylifeup“.
Once you are happy with the hostname, press ENTER to change it.
5. When you quit out of the raspi-config tool, you will be asked if you want to reboot now.
Select “<Yes>” and press ENTER to restart now.
If you don’t restart your Raspberry Pi, other devices will still use the old hostname.
Changing the Raspberry Pi’s hostname using the desktop
If you are using the desktop interface on your Raspberry Pi, changing your hostname is incredibly straightforward.
The reason for this is that the Raspbian operating system provides a simple interface.
1. To open the Raspberry Pi Configuration tool on the desktop, you need to click the icon in the top left-hand corner.
2. With the menu open, hover over “Preferences“, then click “Raspberry Pi Configuration“.
3. Under the “System” tab, you can change the hostname using the textbox (1.).
Once you have set the hostname, click the “OK” button.
4. Upon exiting the dialog, you will be asked if you want to restart.
Click the Yes button to finalize your change.
At this point in the guide, you should now have an idea on how to change the hostname of your Raspberry Pi running the Raspbian operating system.
If you have run into any issues with changing your hostname, feel free to drop a comment below.