Home Raspberry Pi OS Managing the Raspberry Pi OS username and password

Managing the Raspberry Pi OS username and password

by Abraham
raspberry pi os password

The username and password for Raspberry Pi OS (previously known as Raspbian) are fundamental aspects to note. They allow you access to your Raspberry Pi, making it impossible to access your Pi without them. A user uses the username and password every time they want to connect to their Raspberry Pi, whether by physically accessing it or connecting remotely over SSH.

The default password and username required to log in to Raspberry Pi OS are simple and easy to remember, but they come with a threat to your privacy and security.

By default, the username for the Raspberry Pi OS operating system is “pi,” while the login password is “raspberry.”
If you experience trouble remembering the username and password above, keep in mind that they are made up of the name of the device, “raspberry pi.”

How to change the password on Raspberry Pi OS

Now that we have understood how easy it is to remember the default login details for Raspberry Pi OS, it is also important to note that it is not secure. Therefore, it should be changed to one that is a bit more secure.

Below is a step-by-step guide follow it to change the password:

1. First and foremost, open up a terminal session.

2. While in a terminal session, run the following command to change the password:


3. As you run the command above, you will be required to enter the password you are currently using before going on.
By default, the Raspberry Pi OS password is raspberry which you will now input (assuming you are using the default password).

4. After you are done entering the current password, you will now be asked to input a new password that you will be using as a login to Raspberry Pi OS.

5. You will be required to type the new password for the second time to confirm the password change for the Raspberry Pi.


passwd command

Note: SSH keys can combine the security of a passcode with a long and unique encryption key to make it much harder to break into your Raspberry Pi remotely. Therefore, You can further improve your Raspberry Pi’s security by using the SSH keys to enable you to access it remotely.

How to change the default Raspberry Pi username

As you already know, Raspberry’s Pi default username is “pi” while the password is “raspberry.” it is recommended to change the password as shown above and the username. In most cases, changing the username ensures your Raspberry Pi is more secure. So stick to this article to learn how to change the default username in your Raspberry Pi.

If you want to change the default username on your Raspberry Pi, the command to be used is:


This is a Linux command used in changing all the Linux account parameters, including the account name. in this article, I will be showing you the three most common but efficient methods of changing a Raspberry Pi username:

  • using the usermod command
  • manually changing the username 
  • creating a new user with your desired username.

Method 1: Using the usermod command to change the default username

The first method that is widely used is using the usermod command. This method is quite challenging since you cannot change a username directly from an ongoing Pi session. Therefore, you will need to use another user or refer to the method I usually use, logging in as a root user. 

Logging in as a root user grants you the privilege to change the username just like it would if you use another user.

Note: It is impossible to change the username directly on a Pi session without using the root privileges. this is quite dangerous as you might run into errors that might threaten your Pi in the long run.


Enable Root

To change the default username, we shall require a user with root privileges, and the most natural way to get this user is by enabling root.

In this step, you will either be logged in using the SSH method or the GUI method. For the sake of this tutorial, we shall be using the GUI method. 

Open the terminal and paste the command below:

sudo passwd
sudo passwd

sudo passwd

This command will set up a password for the root that we shall use in logging in.

Note: You can ignore this step if you already have a password set for your Raspberry Pi.

Enable SSH

To enable SSH, you will need to go to interfaces and enable SSH.

Note: This process is not mandatory; however, it must be included for educational purposes since it might help those needing the SSH method.

If you plan on changing the default username using the SSH method, then you should first enable root access for SSH before commencing to the step-by-step guide provided below:

Open the SSH configuration file using the command below:

sudo nano /etc/ssh/sshd_config
sudo nano configuration

sudo nano configuration

Search and find the line below:

#PermitRootLogin prohibit-password
permitrootlogin prohibit password

PermitRootLogin prohibit-password

Replace the line above with:

PermitRootLogin yes
permitrootlogin yes

permit root login, yes

Now save the SSH configuration file and exit.

On your terminal, copy and paste the command line below:

sudo service ssh restart
sudo service ssh restart

sudo service ssh restart

That’s all you have enabled root access via the SSH method. Now you can proceed and change the default username on your Raspberry Pi.

Follow these steps after enabling the root to change the default username:

  • login as a root user (Here you can use any method that favors you depending on your preference)
  • we shall be using the syntax below:
usermod -l <new_user> pi


Open the terminal and paste the command below:

usermod -l kip singleboardbytestuts

You have successfully changed the username.

usermod change username from singleboardbytestuts to kip

usermod change username from singleboardbytestuts to kip

Note: while running the command above, I am logged in to “singleboardbytes” therefore, if I try changing the username to “kip”  using the logged-in session, I get the error shown in the screenshot below: to evade the error I use the other username “singleboardbytestuts” that is not logged in.

singleboardbytes is currently in use

singleboardbytes is currently in use

Note: you can also change or rename the home directory by using the syntax statement below:

usermod -m -d  /home/<new_user> <new_user>


To change/rename our home directory, copy and execute the following command in your terminal:

usermod -m -d /home/singleboardbytes singleboardbytestuts

After changing the username, you can test it out by login in with the newly created username. 

Note: The password of the newly created or changed username will be the same as the previous one. Most probably, it should be “raspberry” if you did not change the default password.

After successfully changing the username, you might want to revert to previous settings, such as disabling SSH root access and enabling auto-login. 

To altogether disable the root user, execute the command below:

sudo passwd -l root

If this method fails, you could refer to method two below: changing the default username manually

Method 2: Manually changing the default username

Since the last process might seem hectic, this method chips in as a rescuer. However, it would help if you were very keen since a simple misspelling might cause your Pi to misbehave or even crash. also, the previous method incorporates the best practice, but if you don’t mind about best practices, then you can dive deep into this method

We shall manually change the default username by replacing the “pi” with our desired new username. 

Note: you can only change the username manually if you are logged in as a root user

Open your terminal and switch to root user using the command below:

sudo su
sudo su command

sudo su command

Note: This method can be done inside a Pi session, unlike the previously mentioned method.

Next, copy and paste the commands provided below into your terminal and execute them:

sed -i s/pi/<new_user>/g /etc/passwd
sed -i s/pi/<new_user>/g /etc/shadow
sed -i s/pi/<new_user>/g /etc/group
sed -i s/pi/<new_user>/g /etc/sudoers
sed -i s/pi/<new_user>/g /etc/gshadow
mv /home/pi /home/<new_user>


We shall change our default “pi” username to “singleboardbytes.”

sed -i s/pi/singleboardbytes/g /etc/passwd
sed -i s/pi/singleboardbytes/g /etc/shadow
sed -i s/pi/singleboardbytes/g /etc/group
sed -i s/pi/singleboardbytes/g /etc/sudoers
sed -i s/pi/singleboardbytes/g /etc/gshadow
mv /home/pi /home/singleboardbytes
change the default username from pi to singleboardbytes

change the default username from pi to singleboardbytes

You can see from the screenshot below that the home directory has been changed from pi to singleboardbytes

singleboardbytes home directory

Singleboardbytes home directory

The “sed”  command is helpful as it aids replace one word with another in a given file.

Method 3: Creating a new user

Mostly this method is used as the last option if the two previous methods have failed. follow the steps below to create a new Raspberry Pi user:

  • Login to your Raspberry Pi using the default password and username

After successfully configuring all the required settings, create a new user as shown herein:

  • Add a new user using the command adduser as shown below:
sudo adduser singleboardbytes
  • After executing the command above, you will be required and prompted to enter additional information. For instance, a new password will be required. 
  • Please enter the new password and leave the other settings as they are (default).
    sudo adduser singleboardbytestuts

    sudo adduser singleboardbytestuts

That’s all you have successfully created a new user with a different username. We hope the methods mentioned above helped.

In summary, Since Raspberry Pi comes with a weak security login detail by default, you can use it for small day-to-day activities, at home or in a small network, and it would not be that big of an issue. But if you use it as a WiFi access point or open ports on the internet and further use it in a more extensive network, you will need to take more measures to protect it such as changing the default password and username.


This short article explains the default Raspberry Pi OS username and password and the easiest and recommended ways to change the default Raspberry Pi OS password and username to make your Raspberry Pi more secure. We hope the article was helpful. If yes, give a thumbs up.

You may also like

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.