How to add new users and add users to groups on your Raspberry Pi
If multiple people are using the same Raspberry Pi you may want to add new users so each person has their own user account.
Adding a new user is simple enough, the following method was done whilst logged in as the default user 'pi' which has the root or 'sudo' privileges needed to add and modify user accounts.
For this example we will create a new user called 'newuser', simply replace this with whatever name you want. To add the user 'newuser' use the following command:
sudo adduser newuser
This will create a new user along with a group 'newuser' and new home directory. You'll also be prompted to enter a password for the new user. If you ever need to change the password of the 'newuser' you can do so with the command:
sudo passwd newuser
In order for the user to have the same privileges as the default account 'pi' we'll need to add the it to several user groups. To find out what groups the user 'pi' belongs to type the following command:
groups pi
You can see pi belongs to several groups such as 'audio' and 'video'
Do the same for the 'newuser':
groups newuser
You'll see it only belongs to one group 'newuser'
We need to add new user to the same groups as the user 'pi' to enable him to use audio, accelerated video, pluggable devices, etc
To add a user to a group we use the command:
sudo adduser
So to add 'newuser' to the group 'dialout' type:
sudo adduser newuser dialout
Now repeat this step for all the remaining groups apart from the group 'pi'. If you don't want the new user to have admin or root ('sudo') privileges then don't add the user to the groups 'sudo' or 'adm'.
You can check the user has been added to correct groups by using the command groups newuser again.
Deleting a user and removing a user from a group
If you want to remove a user from a group you can use the following command:
sudo deluser
So to remove user 'newuser' from the group 'adm' you would type:
sudo deluser newuser adm
A similar command can be used to delete an entire user along with it's home directory:
sudo deluser