Change your username with usermod and a home directory rename
The fastest way to change your Raspberry Pi username is to use the usermod command to rename the account, then rename the home directory to match. You will need to log in as a different user or use sudo to do this, because you cannot change the username of the account you are currently using. If you are the only user on the Pi, create a temporary admin account first, log into that account, then change your original username.
The actual steps are: log in as a user with sudo permission (or create one), run usermod -l newusername oldusername to change the account name, then run usermod -d /home/newusername -m oldusername to move and rename the home directory. After that, log out and log back in with your new username to confirm it worked.
Key Takeaways
- You cannot change the username of the account you are currently logged into, so you need a second admin account or the root user to make the change.
- The usermod command changes the account name, but you must also rename the home directory or the system will not find your files.
- If you are the only user, create a temporary admin account, switch to it, then change your original username and delete the temporary account afterward.
- After changing your username, log out completely and log back in to verify the change took effect and that your home directory is accessible.
Create a temporary admin account if you are the only user
If you are the only user on your Raspberry Pi, you cannot use usermod on your own account while logged in. The simplest solution is to create a second temporary account with sudo permission, switch to that account, then change your original username.
Log in as your current user and run sudo useradd -m -G sudo tempuser to create a new account called tempuser with a home directory and sudo permission. Then set a password for it with sudo passwd tempuser. After that, log out by typing exit or closing your terminal, then log back in as tempuser using the password you just set.
Rename the account with usermod
Once you are logged in as a different user (or as root), you can rename the account you want to change. Run sudo usermod -l newusername oldusername, replacing newusername with what you want and oldusername with your current username. This changes the account name in the system files but does not move your home directory yet.
The usermod command works silently — if there is no error message, the rename succeeded. You can verify it by running cat /etc/passwd | grep newusername to see the account listed with its new name.
Rename the home directory to match
After changing the account name, you must rename the home directory so the system can find your files. Run sudo usermod -d /home/newusername -m oldusername. The -d flag sets the new home directory path, and the -m flag tells usermod to move the contents of the old directory to the new location.
This command does the actual file move, so it may take a few seconds if you have a lot of files. When it finishes, your old home directory at /home/oldusername will be gone, and all your files will be at /home/newusername.
Log in with your new username to confirm the change
Log out of your temporary account by typing exit, then log back in using your new username and your original password. If the login works and you can see your files, the rename was successful.
If you created a temporary account, delete it now that you no longer need it. Log back into your renamed account, then run sudo userdel -r tempuser to remove the temporary account and its home directory.
Fix permissions if you cannot access your files
If you log in successfully but cannot read or write files in your home directory, the directory permissions may have been set incorrectly during the move. Run sudo chown -R newusername:newusername /home/newusername to give your account ownership of all files in your home directory.
If you still have problems, check that the home directory path in /etc/passwd is correct by running grep newusername /etc/passwd. The output should show your username, followed by a colon, then the path /home/newusername. If the path is wrong, run usermod again with the correct path.
Change your username back if something goes wrong
If the rename caused problems, you can undo it by running the same commands in reverse. Log in as your temporary account (or as root), then run sudo usermod -l oldusername newusername to change the name back, followed by sudo usermod -d /home/oldusername -m newusername to move the home directory back to its original location.
After that, log out and log back in with your original username to confirm the revert worked. This is why keeping a temporary account available until you are certain the change is working is a good idea.
Frequently Asked Questions
Can I change my username without creating a temporary account?
No — you cannot run usermod on the account you are currently logged into. You must either create a temporary account, log in as root (if you have root access), or use another device to connect remotely and make the change. Creating a temporary account is the safest method for most users.
What happens to my files when I rename my home directory?
The usermod command with the -m flag moves all your files from the old directory to the new one. Nothing is deleted or lost — the directory is renamed and relocated. After the move, /home/oldusername no longer exists, and all your files are at /home/newusername.
Do I need to change anything else after renaming my username?
Most applications will work fine with your new username. However, if you have scripts or configuration files that reference your old username by name, you may need to update those manually. Check any cron jobs, shell scripts, or process config files in your home directory.
What if I forget my password after changing my username?
You can reset it by booting into single-user mode or using the Raspberry Pi recovery tools. If you have another admin account, you can also run sudo passwd newusername to set a new password without knowing the old one.