The fastest way to change your Raspberry Pi username
The quickest method is to use the usermod command while logged in as root or with sudo access. Open a terminal on your Raspberry Pi and run this command, replacing "oldusername" with your current username and "newusername" with what you want:
sudo usermod -l newusername oldusername
This renames the login name itself. However, this command alone does not rename your home directory — the folder where your files live. To rename that folder too, run a second command:
sudo usermod -d /home/newusername -m newusername
After both commands complete, log out, then log back in with your new username and password. Your files, settings, and permissions stay intact.
Key Takeaways
- Use sudo usermod -l newusername oldusername to change the login name, then sudo usermod -d /home/newusername -m newusername to move your home folder.
- You must have sudo access to run these commands — the default "pi" user has this permission.
- Log out and back in after the commands finish to confirm the change worked.
- If you cannot log in afterward, you can still fix it by booting into single-user mode or using another admin account.
Why you might need to rename your home directory
The usermod command with the -l flag changes only the username in the system's user database. Your home directory — normally at /home/pi or /home/oldusername — keeps its old name unless you tell it to move.
This mismatch usually does not break anything, but it can confuse you later. Programs sometimes look for files in /home/username, and if your username is "alice" but your folder is still called "pi", you may see unexpected behavior. Running the second command with the -d and -m flags moves the entire home directory to match your new name.
What to do if you only have one user account
If you are the only user on the Raspberry Pi and you do not have a second admin account, you cannot straightforward log out and run usermod on yourself — you are still logged in. Instead, open a terminal and run both commands from there. The system will let you change your own username even while you are using it, though you will need to log out and back in for the change to take effect everywhere.
After you run the commands, close the terminal, log out from the desktop (or type exit in the terminal), and then log back in with your new username. If you are working over SSH, your connection will drop, and you will need to reconnect with the new username.
Checking that the change worked
After logging back in, open a terminal and type whoami. The output should show your new username. Then type pwd to see your current directory — it should show /home/newusername. If both match what you set, the rename is complete.
You can also check the system files directly by running cat /etc/passwd and looking for your new username in the list. Your entry should show the new home directory path as well.
Fixing permissions if something goes wrong
If you renamed the username but did not move the home directory, or if files in your home folder suddenly show the wrong owner, you can fix the permissions. Run this command to make sure your new username owns everything in its home directory:
sudo chown -R newusername:newusername /home/newusername
The -R flag means "recursive" — it fixes the owner of the folder and everything inside it. If your home directory is still at the old path, replace /home/newusername with the actual path.
Renaming the username using the GUI (if you have a desktop)
If your Raspberry Pi is running a desktop environment like Raspberry Pi OS with the graphical interface, you can also change your username through the settings. Open the menu, go to Preferences, then look for Users or Account Settings. However, the command-line method is faster and more reliable, especially if you are working over SSH or on a headless Pi with no monitor.
The GUI method may also require you to create a temporary admin account first, which adds extra steps. The usermod commands skip that entirely.
What happens to your files and settings
Changing your username does not delete or move your files unless you explicitly tell it to. Your documents, photos, configuration files, and installed programs all stay where they are. The only thing that changes is the name the system uses to refer to you and the path to your home directory.
If you have cron jobs (scheduled tasks) or services that run under your username, they will continue to work after the rename. However, if any script or program has your old username hardcoded in it, you may need to update those manually. This is rare on a personal Raspberry Pi, but worth checking if you have written custom automation.
Frequently Asked Questions
Can I change the username without changing the home directory path?
Yes. Run only the first command: sudo usermod -l newusername oldusername. Your home folder will stay at /home/oldusername, but your login name will be new. This works fine for most uses, though it can be confusing to see a mismatch.
What if I get a "user is currently used by process" error?
This means you are still logged in as that user. Log out completely, then log in as a different admin user (or use SSH from another machine), and run the commands. If you have only one account, restart the Raspberry Pi in single-user mode to make changes.
Will changing my username break my WiFi or network settings?
No. Network settings are stored separately from the username and are not affected by the rename. Your Raspberry Pi will connect to the same networks after the change.
Can I undo a username change?
Yes. Run the usermod commands again, but swap the old and new names: sudo usermod -l oldusername newusername, then move the home directory back. You can rename as many times as you need.
Do I need to change the hostname too?
No. Your hostname (the name of the Raspberry Pi on the network) is separate from your username. You can change it independently if you want, but it is not required when you rename your user account.