4) Create a new user and delete the pi user

<-- Previous    Next –>

We need to completely delete the existing “pi” user because it is a security issue. Everyone knows that a Raspberry Pi has a default user name of “pi” so we need to replace that.

To create a new user we use the adduser command but we have to make sure that the new user is in the same group as the existing pi user.

In the terminal, type:

groups pi

which will list all the groups that this user is in. The output will look something like this:

pi adm dialout cdrom sudo audio video plugdev games users netdev input

We need to create a new user with the same group allocation.

To create a new user, use the useradd command with a list of all the groups copied from the above list less the pi group. In my case it looks like this but yours will look slightly different:

sudo useradd -m -G adm,dialout,cdrom,sudo,audio,video,plugdev,games,users,netdev,input <yourusername>

where <yourusername> is the new username that you are adding.

Now create the password using:

sudo passwd <yourusername>

Enter in the new password and reboot using:

sudo shutdown -r now

Now login with the new username.

Deleting the default ‘pi’ user

Now we can delete the pi user with:

sudo deluser pi

The original pi user and associated files should now be deleted.

<-- Previous    Next –>