Raspberry Pi stands as one of the remarkable inventions, a compact and affordable computer developed by the Raspberry Pi Foundation to establish a system where users of all ages can learn coding and integrate their technological ideas into life.
Since 2015, the Raspberry Pi Foundation has formally offered Raspbian as the primary operating system on Pi devices. Although easy to use, Raspbian brings along security concerns. To ensure greater system security, you can modify your account password. Changing the password on Raspberry Pi is not as straightforward as changing a computer or Windows user account password, so follow the instructions below carefully.
Changing Password on Raspberry Pi
Creating a Superuser and Setting a New Password
By default, the Admin or Superuser is referred to as “pi” with the password being “raspberry”. Clearly, this is insecure as any user could access your computer and engage in unauthorized activities.
So, the first thing you need to do is create a new user (sudo). Enter the following command into the Terminal window (remember to replace rob with the username you want to use):
sudo /usr/sbin/useradd --groups sudo -m rob
Now, the superuser name has been successfully created. The next step you need to take is to assign a password to it. To do this, enter the following command into the Terminal window:
sudo passwd rob
You will be prompted to enter a password. Remember to choose a strong and hard-to-guess password. Avoid using common passwords, and try to combine both numbers and letters, special characters, the longer the better. Enter the password again to confirm.
Before proceeding with the next steps, you need to verify whether the new user account has been set up correctly or not. If you are using the command line interface or SSH, you can skip this step.
If you are using the full version of Raspbian, access Menu (Raspberry Pi logo) =>Preferences =>Raspberry Pi Configuration and uncheck the Auto login as current user box, then click OK to save the changes.
Once completed, restart the system:
sudo reboot
Next, check if you have activated sudo under Admin privileges or not. Log in with the new user account you just created, open Terminal, and run the following command:
sudo groups
Enter the password when prompted. The next step is to disable the default “pi” user.
Disable the “Pi” User
At this point, the “Pi” user still needs certain system functions. Instead of deleting the account (which could lead to other serious issues), you just need to lock the account by expiring the password. To do this, enter the following command into the Terminal window:
sudo passwd -l pi
Try to verify by restarting the device, then logging in with the Pi user, and you will receive a notification that login is not possible.
Install Updates
After modifying the default user settings, it's essential to ensure that your computer is always updated with the latest security patches. To do this, simply run the following command:
sudo apt-get update && sudo apt-get dist-upgrade
You will be prompted to enter a password. Assuming there are updates available, the command will notify you of the disk space occupied by the updates on the SD card, and prompt you to press Y or N to continue. Press Y and then Enter to execute the updates.
At this point, you have updated all installation packages. It's worth noting that previous updates are stored on the computer, depending on the available space on the SD card, you can use the following command to delete previous updates:
sudo apt-get clean
Here is how to change the password on Raspberry Pi. Hopefully after reading this article you have learned how to disable “pi” and update your system more securely. Share your thoughts with Mytour.