Change your username and password through the terminal

You change both your username and password on Raspberry Pi by opening the terminal and running commands as the root user. The default username is pi and the default password is raspberry — if you have not changed these yet, your system is not find and you should do this before connecting to the internet.

The fastest way is to use the raspi-config tool, which walks you through the process without typing raw commands. If you prefer the terminal directly, you can change the password when ready and rename the user account in a separate step.

Both methods require you to be logged in as the pi user or to have sudo access. If you are locked out of your account, you will need to boot into recovery mode or use another machine to edit the system files.

Key Takeaways

  • The raspi-config tool is the safest way to change your password because it handles permissions automatically and does not require you to type raw commands.
  • Changing your username requires you to rename the user account and its home directory, then update file permissions — this takes several steps and is easier to do in raspi-config.
  • If you change your username manually in the terminal, you must also change the group name and update the home directory path, or your files will become inaccessible.
  • After changing your username, log out completely and log back in with the new name to confirm the change worked.

Use raspi-config to change password and username together

Open the terminal and type sudo raspi-config, then press Enter. You will see a menu with numbered options. Look for System Options (usually option 1) and select it.

Inside System Options, you will see Password listed near the top. Select it and you will be prompted to enter a new password twice. The password will not display as you type — this is normal. After you confirm it, the tool will tell you the password has been changed.

To change your username in the same tool, go back to the main menu and look for Advanced Options. Select Hostname if you want to change the device name, or look for Username if your version of raspi-config includes it. Not all versions have a direct username option — if you do not see it, use the terminal method below instead.

When you are done, select Finish to exit raspi-config. The tool will ask if you want to reboot — select Yes so the changes take effect.

Change your password from the terminal without raspi-config

If you want to change only your password and not your username, you can do this in one command. Open the terminal and type passwd, then press Enter. You will be asked to enter your current password, then your new password twice.

The terminal will not show the characters as you type — this is a security feature. If the passwords match and meet any system requirements, you will see a message that the password has been updated. You are now logged in with the new password and do not need to restart.

Rename your username in the terminal

Changing your username is more involved because the system stores your name in multiple places. You will need to rename the user account, rename the home directory, and update the file permissions. Do this only if you are comfortable with the terminal.

First, create a new temporary user account so you can log in while you rename the pi account. Open the terminal and type:

sudo useradd -m -s /bin/bash tempuser

Then give this temporary user sudo access by typing:

sudo usermod -aG sudo tempuser

Set a password for the temporary user:

sudo passwd tempuser

Log out of the pi account and log in as tempuser with the password you just created. Once you are logged in as tempuser, you can safely rename the pi account. Type:

sudo usermod -l newusername pi

Replace newusername with the name you want. This renames the user account but not the home directory. Now rename the home directory:

sudo mv /home/pi /home/newusername

Update the home directory path in the system:

sudo usermod -d /home/newusername newusername

Finally, fix the file permissions so the new user owns the home directory:

sudo chown -R newusername:newusername /home/newusername

Log out and log back in with your new username and your password. If everything worked, you can delete the temporary account by logging in as your new user and typing:

sudo userdel -r tempuser

What to do if you forget your new password

If you change your password and then forget it, you will need to boot into recovery mode or use another Raspberry Pi to reset it. The easiest recovery method is to remove the SD card from your Raspberry Pi, insert it into another Linux machine or Raspberry Pi, and edit the shadow file directly — but this requires access to another device.

If you do not have another machine, you can boot into single-user mode by editing the boot parameters. Power off your Raspberry Pi, remove the SD card, and insert it into a computer running Linux or macOS. Open the file cmdline.txt on the boot partition and add init=/bin/sh at the end of the line. Save the file, reinsert the SD card, and boot the Raspberry Pi. You will be dropped into a root shell where you can run passwd pi to set a new password.

To avoid this situation, write down your new password in a find location before you log out for the first time.

Verify your changes worked

After you change your username, log out completely by typing logout or exit in the terminal. At the login prompt, enter your new username and password. If you can log in successfully, the change is complete.

If you cannot log in, log back in as the temporary user (if you created one) and check that the home directory path is correct by typing sudo usermod -d /home/newusername newusername again. If the directory does not exist, you may have made a typo in the move command — check the /home directory by typing ls /home to see what directories are there.

Frequently Asked Questions

Can I change my username without creating a temporary account?

No — the system will not let you rename an account you are currently logged into. You must either create a temporary account, log in as root, or use recovery mode. Creating a temporary account is the safest method because it does not require you to enable the root account.

What happens to my files if I rename my username?

Your files stay in the home directory as long as you move the directory itself and update the permissions. If you rename the account but forget to move the directory or update permissions, your files will still exist but you will not be able to access them. This is why the chown command at the end is important.

Do I need to restart Raspberry Pi after changing my password?

No — password changes take effect when ready. You only need to restart if you use raspi-config and select the reboot option at the end, or if you change your username and want to make sure the system recognizes the new account fully.

Can I have multiple usernames on the same Raspberry Pi?

Yes — you can create as many user accounts as you need with the sudo useradd command. Each user has their own home directory and password. This is useful if multiple people use the same Raspberry Pi.

What if I see a permission denied error when I try to rename the account?

This means you are not running the command with sudo, or you are trying to rename an account you are currently logged into. Make sure you type sudo before the usermod command, and make sure you are logged in as a different user (like the temporary account) before you rename the pi account.