Debian

How to Add a User in Debian 12

How to Add a User in Debian 12

Debian allows multiple users to access the same system without affecting other users’ privacy. You can add more than one user to the system to maintain security and organize the access control. Two types of users exist in Debian: one is a Regular user while the other is a System user or Super user. The System user has unlimited administrative privileges and the Regular users have only specific permissions. A sudo user can add, delete, or modify the users in Debian 12.

In this guide, we will discuss the two approaches to add a user in Debian 12 i.e. through a terminal and through GUI.

Quick Outline

 

How to Display Users in Debian 12

You can display both the system and regular users on Debian 12 directly from the terminal. If you want to display the system users and regular users in Debian, execute the following command:

cat /etc/passwd

 

How to Add a User in Debian 12 Through Terminal

You can use an adduser command in Debian 12 to add a new user either system or regular.

1: Add a System User in Debian 12

Follow the below-written steps to add a new system user in a Debian 12:

Step 1: The following is the fundamental syntax to use the adduser command in Debian:

sudo adduser username

Replace the username with the name of the new user. For instance, I am adding a user with the name zee:

sudo adduser zee

Step 2: Next, set a password for the added user:

Step 3: Enter the new values for a person such as Full Name, Number, etc or you can press Enter to choose the default values for the added user:

Step 4: Verify the provided information by tapping Y, once done, the user will be added to your system and a message will appear on your system:

Step 5: By default, a new user will be added to the group users and you can verify it by executing the following command:

grep 'users' /etc/group

A new system user will be created successfully on Debian.

2: Add a Regular User in Debian 12

To add a regular user in Debian, you can use the useradd command followed by the group name and the username, the syntax is given below:

sudo useradd -G groupname username

To confirm the addition of the user, view the member of the specified group:

grep 'usergroup' /etc/group

 

How to Give sudo Privileges to a User in Debian 12

Debian allows you to give sudo privileges to users so they can make changes to your system and run all commands as a root. If you have a user that needs certain admin privileges then there are two ways to give sudo privileges to a new user in Debian:

 

1: Add User to a sudo Group in Debian 12

Adding a user to the sudo group will give all the sudo privileges and they can run any command as root via sudo. The following is the general syntax to give sudo privileges to a new user:

sudo usermod -aG sudo username

Here:

-a: It modifies the changes to the current configuration and appends the user to a specified group without removing it from other groups.

-G: It represents the group to add the user to.

Here, I am giving sudo privileges to a newly added user zee in Debian using the below command:

sudo usermod -aG sudo zee

To verify whether the user is added to sudo users or not, use the following command:

groups zee

The new user zee is successfully added to sudo users.

 

2: Edit a sudoers File

First, switch to the root user using the below command because the root user has all the sudo privileges:

su

Next, open the visudo file using any editor, as here we are using nano editor:

nano /etc/sudoers

Add the following line under the User privilege specification and do not forget to replace the username with the name of the user you want to give sudo privileges:

username ALL=(ALL:ALL) ALL

Press Ctrl + X, add Y to save the file, and hit Enter to exit back to the terminal.

Note: To remove a user from the sudo group execute the sudo deluser username sudo command on the terminal.

 

How to Add a User to a Specific Group in Debian 12

The Debian system has several users that are added to a different group and each member of an individual group has the same privileges for reading, writing, and executing the permissions. By default, the user is added to the group users; however, you can add a user to a new group. To do so, first, you have to create a group using the below syntax command:

sudo groupadd group_name

Replace the group_name with the name of the group. For example, I have created a new group called mygroup:

sudo groupadd mygroup

Once you execute the above command, verify whether the group is created using the following command:

grep mygroup /etc/group

Next, add a user zee to a new group mygroup through the execution of the below command:

sudo usermod -a -G mygroup zee

 

You then verify the group of user zee on Debian through the following command:

id zee

 

How to Remove a User From a Group in Debian 12

To remove a user from a group, run the deluser command followed by the name of the user and group. The fundamental syntax of removing a user from the group in Debian 12 is written below:

sudo deluser username group_name

For instance, I have removed the zee user from the mygroup:

sudo deluser zee mygroup

 

How to Delete a User in Debian 12 Through Terminal

Deleting a user on Debian 12 is as simple as adding it. To delete a user on Debian 12, use the following syntax:

sudo deluser username

Replace the username with the name of the user; as in the below example I have deleted a user zee:

sudo deluser zee

You have successfully deleted a user zee from Debian 12.

 

How to Add a User in Debian 12 Through GUI

Another approach to add a new user in Debian is through GUI. All you have to do is follow the below simple steps properly:

Step 1: Navigate to Activities and search for Settings to launch the settings of the system:

Step 2: Scroll down to find the Users option from the left panel and click on it:

Step 3: Click on Unlock to add new users and change the settings; the prompt will appear asking you to enter the password of the administrative account on your system; provide the password and click on Authenticate to continue:

Step 4: Next, click on Add User under Other Users:

Step 5: Provide the information of the user, such as Name, Username, and Password. You can also turn the toggle ON and OFF to make a user administrator:

Step 6: Once you have typed all the relevant information, click on the Add button to add the user to the Debian:

Step 7: The name of the added user will appear under Other Users:

 

How to Delete a User in Debian 12 Through GUI

If you have added a new user in Debian and want to remove it then it can be done from the Settings of the system. Follow these steps to delete a user in Debian 12:

Step 1: Navigate to Activities and search for Settings to open the system’s settings:

Step 2: Scroll down to find the Users option and click on it:

Step 3: Under Other Users, click on the name of the user that you want to remove:

Step 4: The information of the user will appear on your screen, click on Remove User… to delete a user in Debian:

Step 5: A prompt will appear on your screen; you can choose either Delete Files to delete all the files with the user or to Keep Files while deleting a user:

The user will be permanently deleted from Debian 12.

 

Conclusion

The user privileges are an important aspect of managing the security of your Debian system. You can add a regular user as well as a system user on Debian 12. There are two different approaches for adding a user: one is through the terminal while the other is through the Settings of the system. Once you have created a user, you have to give the user sudo privileges for running the sudo commands. We have discussed the steps to create a user, add a user to a group, and provide sudo privileges to users in the above section of this post. Following these methods will help you understand the basics of adding a user in Debian 12.

 

Similar Posts