Change Default Raspberry Pi? What You Need to Know
Yes, you can change the default user account on a Raspberry Pi, but the exact steps depend on which operating system you are running and what you mean by “default.” This article covers changing the default username, password, hostname, and boot behavior, plus what to do if you’ve already set up your Pi.
What Does “Default” Mean on a Raspberry Pi?
When you first boot a Raspberry Pi with Raspberry Pi OS (the official operating system), it comes with a pre-configured user account. For years, that account was pi with the password raspberry. Since the release of Raspberry Pi OS in late 2022, new installations no longer use these universal defaults. Instead, the Raspberry Pi Imager asks you to create a username and password during setup. However, if you are using an older image or a third-party OS like Ubuntu, the default credentials may still apply.
Changing the default involves more than just the password. You might also want to change:
- Username – the login name for your main account.
- Password – the secret phrase used to authenticate.
- Hostname – the name your Pi uses on the network (default is
raspberrypi). - Boot behavior – whether it boots to desktop, command line, or an automated script.
Why Change the Default Credentials?
Security is the main reason. If your Pi is exposed to the internet (e.g., for a web server or remote access), attackers will try the default username and password first. Even on a local network, a malicious device could attempt to log in with pi/raspberry. Changing the default reduces this risk significantly.
Another reason is personalization. If you have multiple Pis, giving each a unique hostname helps you identify them on your network. You might also want a username that matches your own name or a project role, like media or weather.
Finally, some software assumes the user is pi and stores configuration files in /home/pi. Changing the username can break such scripts, so you need to be aware of that before proceeding.
How to Change the Default Password
The simplest change is the password. Open a terminal and run:
passwd
You will be prompted for your current password, then asked to enter a new one twice. The system does not display characters as you type. After success, you’ll see a confirmation message.
If you are using a desktop environment, you can also go to Preferences > Raspberry Pi Configuration > System and click Change Password. This method works for the current user only.
For headless setups (no monitor), you can SSH in and run the same command. Make sure you remember the new password; if you forget it, you may need to reflash the SD card.
How to Change the Default Username
Changing the username is more involved. You cannot simply rename the pi user while it is in use. The recommended approach is to create a new user, give it sudo privileges, then delete the old one. Here is a step-by-step method that works on Raspberry Pi OS (Debian-based):
- Log in with your current account (e.g.,
pi). - Create a new user, for example
newuser:sudo adduser newuser - Add the new user to the
sudogroup:sudo usermod -aG sudo newuser - Log out and log in as
newuser. - Once logged in, delete the old user and its home directory:
sudo deluser -remove-home pi
Be careful: deleting a user removes all files in their home directory unless you back them up first. Also, some services may reference the old username in configuration files (e.g., /etc/rc.local or cron jobs). Check those files for hardcoded paths like /home/pi and update them to the new path.
If you want to keep the same username but change its display name, that is not possible; the username is the login identifier.
How to Change the Hostname
The hostname is the name your Pi advertises on the network. To change it, edit the hostname file:
sudo nano /etc/hostname
Replace the existing name with your desired one (e.g., my-pi). Save the file (Ctrl+X, then Y, then Enter). Next, edit the hosts file:
sudo nano /etc/hosts
Find the line that starts with 127.0.1.1 and change the name after it to match your new hostname. Save and exit. Then reboot:
sudo reboot
After reboot, your Pi will respond to my-pi.local on the network (if mDNS is enabled). This is especially useful if you use SSH or VNC.
Changing Boot Behavior and Default Boot Target
If by “default” you mean what happens when you power on the Pi, you can control that with the Raspberry Pi Configuration tool or the raspi-config command.
- Boot to Desktop – automatically logs in and shows the graphical interface.
- Boot to Desktop with auto-login – skips the login prompt.
- Boot to Console – shows a text login prompt.
- Boot to Console with auto-login – logs in automatically and drops to a shell.
To change this, run sudo raspi-config, go to System Options > Boot / Auto Login, and select your preference. For headless projects, console auto-login is often chosen to run scripts at startup.
You can also change the default target via systemd: sudo systemctl set-default multi-user.target for console, or graphical.target for desktop. This is a more advanced method that works on any systemd-based Linux.
Common Problems and Misconceptions
One common mistake is assuming that changing the password via passwd also changes the username. It does not. Another is forgetting that the default user is used by some services. For instance, if you run a web server as user pi, changing the username without updating the service configuration will break it.
Another misconception: you cannot change the default user on a pre-installed system by simply renaming the home folder. The system tracks users by UID (user ID), not just the name. Deleting and recreating a user with the same name will create a new UID, which can cause permission issues for files owned by the old UID.
If you forget your password and cannot log in, you can reset it by booting from a different SD card or using a recovery mode. On Raspberry Pi OS, you can also edit the kernel command line to boot into single-user mode, but that requires physical access and is not recommended for beginners.
Alternatives to Changing the Default
If you want to avoid the hassle of changing the username, consider using a fresh installation with the Raspberry Pi Imager. The Imager allows you to set a custom username and password during the initial setup. This is the simplest way to have a non-default user from the start.
Another alternative is to use a different operating system that does not have a default user at all, such as Ubuntu Server, which forces you to create a user during installation. Or you can use Docker containers to isolate applications, so you don’t need to change the system user.
For network security, you can also disable password login for SSH and use SSH keys instead. This is often a better defense than just changing the password, because keys are much harder to guess.
Frequently Asked Questions
Can I change the default username without deleting the old one?
Technically, you can rename the user with usermod -l newname oldname, but this is risky. The system may have many files and processes tied to the old name, and you must also rename the home directory and update the group name. It is safer to create a new user and delete the old one, as described above.
What is the default password for Raspberry Pi OS?
For images created with the Raspberry Pi Imager after late 2022, there is no default password; you set it during setup. For older images, the default is raspberry for the user pi. If you have an older image, change it immediately.
Will changing the username break my installed software?
It can. Programs that store settings in /home/pi or run as the pi user may stop working. You will need to update file paths in configuration files and possibly change ownership of files. Check for references to /home/pi in your system and replace them with the new path.
How do I change the hostname without rebooting?
You can use sudo hostname newname to change it temporarily, but the change will revert after reboot. To make it permanent, edit /etc/hostname and /etc/hosts as described, then reboot. There is no reliable way to change it permanently without a reboot.
Is it safe to use the default user if I only use the Pi on a local network?
It is safer than exposing it to the internet, but still not recommended. Other devices on the same network could attempt to connect via SSH or other services. If you have sensitive data or control physical devices, change the default credentials.
What if I forget my new password?
You can reset it by booting from a different SD card and mounting the original card’s filesystem, then editing the /etc/shadow file to remove the password hash. This is advanced and requires another Linux machine. Alternatively, reflash the SD card and restore from a backup.
Related
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.