The fastest way to change your Raspberry Pi username
The simplest method is to use the raspi-config tool, which is built into Raspberry Pi OS. This tool lets you change your username without typing terminal commands, and it handles the file permissions automatically so nothing breaks.
Open a terminal on your Raspberry Pi (or connect via SSH if you are using it headless). Type sudo raspi-config and press Enter. You will be asked for your password — this is the password for your current user account. Once you enter it, a menu will appear with blue and white boxes.
Navigate to System Options using the arrow keys, then press Enter. Scroll down to find Hostname and Username — select Username. The tool will ask you to enter your new username. Type it in lowercase letters and numbers only (no spaces or special characters), then press Enter. The system will confirm the change and ask you to reboot. Select Yes and your Raspberry Pi will restart with your new username active.
Key Takeaways
- Use sudo raspi-config from the terminal to change your username without manual file editing.
- Your new username must be lowercase letters and numbers only, with no spaces or special characters.
- The system will ask you to reboot after the change — allow it to restart so the new username takes effect.
- If you forget your password and cannot run sudo commands, you will need to boot from a different device or use a recovery method.
- Any scripts or cron jobs that reference your old username by path will need to be updated manually after the change.
What happens when you change your username
When you change your username through raspi-config, the system updates your home directory path, your user account record, and all the file ownership that points to your old name. This is why using raspi-config is safer than trying to rename things manually — it does all of this at once.
Your old home directory (usually /home/oldusername) is renamed to /home/newusername. All your files, settings, and installed programs stay in that directory and remain yours. The system also updates your login name, so the next time you log in, you will type your new username instead of the old one.
One thing raspi-config does not change automatically: if you have written any scripts, cron jobs, or configuration files that mention your old username by its full path (like /home/oldusername/myfile), those references will break. You will need to find and update them by hand. Most users do not have these, so this is usually not a problem.
Changing your username from the terminal without raspi-config
If raspi-config is not available or you prefer to do it manually, you can change your username using the usermod command. This method requires more steps and more care, because you have to handle the home directory yourself.
First, create a new user account with your desired username. Type sudo useradd -m -s /bin/bash newusername and press Enter. The -m flag creates a home directory, and -s /bin/bash sets the shell to bash. Then set a password for this new account by typing sudo passwd newusername.
Next, copy all the files and permissions from your old home directory to the new one. Type sudo cp -r /home/oldusername/* /home/newusername/ to copy the files, then sudo chown -R newusername:newusername /home/newusername/ to make sure the new user owns them. After that, log out and log back in with your new username to make sure everything works.
Once you have confirmed that the new account works and has all your files, you can delete the old account. Type sudo userdel -r oldusername to remove the old user and their home directory. The -r flag deletes the home directory as well, so be certain you have copied everything you need before you run this command.
Recovering if you get locked out
If you change your username and then cannot log in, or if you forget the password for your new account, you have a few options. The easiest is to use another device to boot Raspberry Pi OS from a USB drive or SD card, mount your Raspberry Pi's storage, and edit the user files directly. This requires another computer and some comfort with file systems, but it works even if you are completely locked out.
Alternatively, if you have physical access to your Raspberry Pi and it is still running, you can connect a keyboard and monitor, hold down Shift while it boots, and interrupt the boot process to get a recovery menu. From there you can reset your password or create a new user account.
If neither of those options is practical, the safest path is to back up your SD card (if you have one), erase it, and reinstall Raspberry Pi OS from scratch. This is a last resort, but it always works.
Updating scripts and cron jobs after the change
If you have written any shell scripts, Python scripts, or other programs that reference your old username, you will need to update them. The most common place this happens is in cron jobs — scheduled tasks that run on a timer.
To find references to your old username, open a terminal and type grep -r "oldusername" /home/newusername/. This will search your home directory for any files that mention your old username. Look through the results and update any paths or references to use your new username instead.
For cron jobs specifically, type crontab -l to see your scheduled tasks. If any of them contain paths like /home/oldusername/script.sh, edit them with crontab -e and change the paths to use your new username. Save and exit, and the cron job will run with the updated path the next time it is scheduled.
Frequently Asked Questions
Can I change my username without rebooting?
raspi-config will ask you to reboot, and you should allow it — the reboot ensures that all system processes pick up your new username. If you use the manual terminal method, you do not strictly need to reboot, but you must log out and log back in with your new username for the change to take full effect.
What characters can I use in my new username?
Stick to lowercase letters (a–z) and numbers (0–9). Avoid uppercase letters, spaces, hyphens, underscores, and special characters, because they can cause problems with scripts and system tools. A username like pi2024 or myuser works fine; My-User or my user will cause headaches later.
Will changing my username affect my WiFi or network settings?
No. Your network settings are stored separately from your username and will continue to work after the change. Your Raspberry Pi will reconnect to your WiFi network automatically.
Can I have multiple usernames on the same Raspberry Pi?
Yes. You can create additional user accounts without removing your current one. Use sudo useradd -m -s /bin/bash username to create a new account, then sudo passwd username to set its password. Each user will have their own home directory and login.
What if I want to change the hostname too?
The hostname (the name your Raspberry Pi shows on your network) is separate from your username. You can change it in raspi-config under System Options > Hostname. Changing the hostname does not affect your user account or your files.