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:
which will list all the groups that this user is in. The output will look something like this:
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:
where <yourusername> is the new username that you are adding.
Now create the password using:
Enter in the new password and reboot using:
Now login with the new username.
Deleting the default ‘pi’ user
Now we can delete the pi user with:
The original pi user and associated files should now be deleted.