User Management

In the past the Raspberry user name was pi and and often used with the default password. This is easy to remember but the opposite of being secure. Fortunately newer Raspberry OS will ask for a username and password.

Important

For old Raspberry installations just delete the user pi when having a new user that is capable of using the sudo command. Use the user pi to setup permission for the new user

The following shows how to remove the pi user from an old Raspberry installation:

sudo adduser <username> creates a new user and files from /etc/skel are copied over to the new /home/<username> directory

lslogins -u shows the logins on the system

getent passwd <username> to see its password entry, x is there for historical reasons to tell that the password is encrypted and just a password salted hash is in /etc/shadow

groups <username> shows what groups the user belongs

groups pi shows what groups pi belongs

To do the same as pi copy all groups of pi to the following command

sudo usermod <username> -a -G pi,adm,dialout,cdrom,sudo,audio,video,plugdev,games,users,input,render,netdev,spi,i2c,gpio

To work with sudo as pi (do not use a regular editor since mistyping could end up in troubles)

sudo cp /etc/sudoers.d/010_pi-nopasswd /etc/sudoers.d/010_<username>-nopasswd and then

sudo visudo -f /etc/sudoers.d/010_<username>-nopasswd replace pi with <username> inside the new copy

Important

If very sure pi is no more needed and other users can do sudo pi can be removed.

sudo deluser --remove-home <username> to delete a user and its home directory,


Linurs startpage