Raspberry Pi user management : How To Add, Delete, and Grant Sudo Privileges to Users on linux

User_Management
2 minutes read

I hope that you are aware of Raspberry Pi and have a working Raspberry with Raspbian installed. Now if you want to add new user, Grant sudo access to this user and then delete a specific user, please follow this blog.

If you are not aware of Raspberry Pi, then please check the blog “What is Raspberry Pi ?” and then to install OS(Raspbian) on Raspberry Pi check the blog “Starting/Booting Raspberry Pi“. You may also purchase a new Raspberry Pi(Purchase single unit or full package[recommended]) from amazon.

Adding new user on Linux

Note :- It has been assumed that you have logged in as default user pi which has sudo access. If you are logged in as root you can omit the usage of sudo.

You may add new user by the following command. Fill in all the required information or press enter to skip. For example we will add a user named shashank.

sudo adduser shashank
Creating_User
Creating a new user

Now you may switch to this user by giving in the following command.

sudo su shashank
Switch_User
Switching User

Note :- su means switch user

Grant Sudo Privileges to this users

Note :- sudo menas substitute user as. Here we are substituting our user as root to get the privileges of root user.

On Raspberry Pi you may add the new user to the sudo group to give them the sudo access. For example let us consider the group name as sudo and user name shashank.

sudo usermod -aG sudo shashank
User_Add
Adding user to sudo group

Note :-  -aG means add user to the group.

Now you can use sudo with this new created user.

Create a New User and Assign sudo Group in One Command

You may also use this single command to create a new user and add it to the sudo group.For example let us consider the group name as sudo and user name shashank.

sodo useradd -G sudo shashank
Add+sudo
Adding User and assigning sudo access

Deleting a user

You may login as root or any user which has sudo access to delete a user. While using root there is no need to use sudo keyword. For example let us consider the user name shashank.

sudo deluser --remove-home shashank
Delete_User
Deleting User

Note :- If you want to reset password for any user then please follow the blog “Raspberry Pi password management : How to reset passwords on linux“.

 

References – How to Geek and Digital Ocean

4 Replies to “Raspberry Pi user management : How To Add, Delete, and Grant Sudo Privileges to Users on linux”

  1. With thanks! Valuable information!

  2. With thanks! Valuable information!

  3. We are a group of volunteers and opening a new scheme in our community. Your website offered us with valuable info to work on. You’ve done a formidable job and our entire community will be thankful to you.

  4. With thanks! Valuable information!

Leave a Reply