Delete Pi User on Raspberry Pi



One of the first things you should do when setting up the Raspberry Pi is to change the default password for the pi user. Personally, I would rather just delete the user altogether and create my own user. So here’s how I deleted the Pi user on Raspberry Pi.

Step 1: Create a New User

Before you begin, make sure that you can SSH into your Raspberry Pi . I first began by creating a new user on the Raspberry Pi. To do so, I entered the following command:

sudo adduser dave

It will prompt you to create a password and fill in other account information. Next, I went ahead and added this new user to the sudo group. This is so that I can use the sudo command in this account.

sudo usermod -aG sudo dave

The -a parameter tells the usermod to append to the given group (-G) which we specified as sudo.

Step 2: Delete Pi User

For some reason, deleting the Pi user was more of a challenge than I wanted it to be. To delete the Pi user on Raspberry Pi, there are a couple of steps you’re going to need to get through. First, change the autologin in the display manager. Type in the following:

sudo nano /etc/lightdm/lightdm.conf

Then navigate down to where you see autologin-user and change it to the username that you want. Remember, in the nano text-editor you can use CRTL + O to save. Now we need to do the same thing in the raspberry config. Type in the following:

raspberry-config

You will see a window appear. Go to boot-options and the CLI sub menu. From there, I changed the option to require login on boot and not autologin.

Finally, once you are ready reboot your raspberry pi:

sudo reboot


Now login to your Pi using the new user. Then run the following command to officially delete  the Pi user:

sudo userdel -r pi

That’s it! That’s how I went about deleting the pi user on Raspberry Pi.