The easiest way to find your Raspberry Pi’s hostname is through the command line interface (CLI). Follow these simple steps to check it.
The hostname is a unique identifier for your Raspberry Pi on a local network or the internet. Knowing its hostname can be useful when accessing it remotely, configuring network settings, and more. In …
Updated August 3, 2023
The hostname is a unique identifier for your Raspberry Pi on a local network or the internet. Knowing its hostname can be useful when accessing it remotely, configuring network settings, and more. In this article, we’ll show you how to find your Raspberry Pi’s hostname using the command line interface (CLI).
- Open a terminal window on your Raspberry Pi by clicking on the icon in the top left corner of the desktop or by pressing
Ctrl + Alt + T
. - Type
hostname
and pressEnter
. This will display the hostname of your Raspberry Pi.
For example:
pi@raspberrypi:~ $ hostname
raspberrypi
In this case, the hostname is “raspberrypi”. If you want to change it, follow these steps:
- Open the
sudo nano /etc/hostname
file by typingsudo nano /etc/hostname
in the terminal and pressing Enter. This will open the hostname configuration file with nano text editor. - Replace the current hostname with your desired one. Save the changes by pressing
Ctrl + O
, then exit nano by pressingCtrl + X
. - Open the
sudo nano /etc/hosts
file and replace all instances of the old hostname with the new one usingCtrl + W
. Save the changes and exit nano as before. - Reboot your Raspberry Pi to apply the changes by typing
sudo reboot
and pressing Enter. - After the reboot, check if the hostname has been changed correctly by running
hostname
in the terminal again.