How to Change Your Raspberry Pi's Hostname

How to Change a Raspberry Pi Hostname
(Image credit: Tom's Hardware)

By default, any Raspberry Pi that uses Raspberry Pi OS, the official OS, has “raspberrypi” as its hostname. So, whether you’re trying to use your Raspberry Pi as a web server or set up a headless Raspberry Pi that you access remotely, your board will always be listed as “raspberrypi” on your network. That’s not very helpful when you have multiple Raspberry Pi devices and can’t tell one from the other.

Fortunately, it’s very easy to rename your Raspberry Pi in Raspberry Pi OS.There are three main ways to change the Raspberry Pi’s hostname and, which one you choose, really depends on your preference for command line or desktop environment. Note that your Raspberry Pi hostname can have numbers, letters, capital letters and hyphens (as long as the first character isn’t a hyphen) but it can’t have special characters.

Latest Videos FromTom's Hardware
Avram Piltch
Managing Editor: Special Projects

Avram Piltch is Managing Editor: Special Projects. When he's not playing with the latest gadgets at work or putting on VR helmets at trade shows, you'll find him rooting his phone, taking apart his PC, or coding plugins. With his technical knowledge and passion for testing, Avram developed many real-world benchmarks, including our laptop battery test.

  • k9gardner
    I've just discovered that the methods outlined are not equivalent. I used the system Preferences GUI method, which seems equivalent to editing raspi-config, and it also affects /etc/hostname. However, after making this change, the value in /etc/hosts remains unchanged. This will cause errors when trying to elevate a command (sudo) as the new identity is not defined in the place where the system is looking for it. You'll get an "unable to resolve host" error each time. Editing the /etc/hosts value should correct this situation. Or so I hope. I'm about to do it.
    Reply