Learn how to create and delete your user accounts on your Debian 8 system easily.
The creation of a user is a simple process, but we must be careful to assign the correct permissions so that the user if it is the case, does not have administrative access and can make changes in system parameters affecting the stability and performance of it.
In this tutorial w, will analyze how to create a user, assign privileges and delete it from a Debian 8 environment.
For this case we will create and edit a user called access.
How to Create User in Debian 8
For the creation of a user in Debian 8 we have two possibilities depending on how we have logged in, like this:
- If we are as root users we will enter the adduser access command.
- If we are not as root users we will enter the command sudo adduser access.
The operating system automatically asks for the password for the new user which must be confirmed and establish a series of additional data which are not mandatory to enter them so that we can press Enter to leave said space in white.
In this way we have created the user access in a simple way. With the command adduser we have created the user, a new group and a personal directory for that user.
How to assign Sudo privileges to a user on Debian 8
It is possible that for some administrative task it is necessary that the new or existing user requires access with the privileges of sudo to the system to execute certain tasks.
First, we will verify the current groups of said user using the following syntax:
We can see that by default the new user is only in his own group. To add this user to a new group, we will use the usermod command in the following way.
The -aG parameter tells usermod to add the user in the indicated groups.
usermod - aG sudo access
To validate the new group we will use the groups access option again and we will see the new group added in the user's profile.
In this way, the new user will have administrative privileges and at the next session start will be able to execute commands in a normal way using the syntax ls ~.
We can also execute commands with administrative privileges using the following syntax:
sudo ls /root
How to specify privileges to a user in Debian 8
The path /etc/sudoers contains all the privileges of the users of the system and for its edition we can use the visudocommand if we are as root users or sudo visudo if we do not have these privileges.
It is essential to be careful with how we manage the /etc/sudoers file.
Locate root ALL=(ALL:ALL) ALL and just below it we will add our user with the same format:
We save the changes using the key combination: Ctrl + O
Exit the editor using the keys: Ctrl + X
How to Remove a User in Debian 8
When a user leaves the organization, it is important, for security reasons, to delete it from the system.
For this we can execute the following command:
- Root users deluser access.
- No root users we will enter sudo deluser access.
If we want to remove, together with the user, the director home we will enter the following command:
deluser --remove-home access
If we have established the permissions for the path /etc/sudoers it will be necessary to enter again using the visudo command and eliminate the row associated with the user, in this case
access ALL=(ALL:ALL) ALL
, In this way we have the possibility to manage everything related to users in Debian 8 ensuring secure access and with the required permissions. If in addition to this system, you have the habit of using Windows, here we leave you how to also add local accounts in Windows 10.