Debian

How to Add a User in Debian 12

User management is one of the important tasks in an operating system that allows you to create and manage multiple user accounts on the system. Creating multiple users is beneficial because it allows you to have separate user accounts that can help protect your privacy. Besides that, different users have their personalized desktops, applications and settings. Thus, it makes it easier to find out what you need. Adding a new user on Debian 12 is a simple task that can easily be done if you are a beginner as well.

In this guide, you will learn:

How to Add a User in Debian 12

You can add a user in Debian 12 using:

How to Add a User in Debian 12 Using Terminal

You can add a user in Debian 12 using the adduser command in the terminal, this can be done from the following steps:

Step 1: First, open terminal and run the following adduser command with the required username you want to add on Debian:

sudo adduser username

Here, I have added username as linuxhint on Debian 12 using the command:

sudo adduser linuxhint

Note: You should run the above command with sudo privileges because you are going to do changes within the system.

Step 2: You must set a password for the new user you have added to the system:

Step 3: Enter the new value for the user you have added. You can also go with the default ones by pressing the Enter button on the options that appears on the terminal:

Step 4: Reply with Y to ensure the information you provided is correct, once done, your new user will be added to Debian 12:

How to Give sudo Privileges to a New User on Debian 12

After adding a new user, you must grant sudo privileges to that user so that you will be able to run commands in sudo privilege. You can add sudo privileges to your added user on Debian 12 using the following command:

sudo usermod -aG sudo username

To verify whether the new user is added to sudo users in Debian 12, you can use the following command:

groups linuxhint

Besides using the command, you can also configure the sudoers file to give sudo privilege to the new user on Debian 12. For this process, you must log in as the root user on Debian 12 using the following command:

su

Then open the sudoers file using the nano editor from the below-given command:

nano /etc/sudoers

Inside the file, you have to add the following line right under the root user privilege specification:

username ALL=(ALL:ALL) ALL

Note: Replace username with the user you have added to Debian 12:

Then save the file using CTRL+X, add Y and press Enter.

How to Fix username not in the sudoers file on Debian 12

The error username not in the sudoers file is mostly encountered by the Debian users who have recently started using the Debian system and run sudo commands:

By default, Debian doesn’t allow sudo privileges to the users. Thus, you have to add your user to sudoers file or add the user to sudo group using the previous-mentioned methods to fix this issue on Debian 12.

How to Add a User to a Group in Debian 12

Adding a user to a group is a useful task that can be done on Debian since it organizes the users and defines their roles and responsibilities. The users of the same group have the same privileges to execute a task on the system.

To add a user to a group on Debian, you first need to create a group from the command given below:

sudo groupadd group_name

You can then verify the group using the following command:

grep group_name /etc/group

After that, you can add a specific user to your group using the below-given command:

sudo usermod -a -G group_name username

To verify the identity of the user on Debian 12, you can use the command given below:

id username

How to Add a User in Debian 12 Using GUI

You can also add a user in Debian 12 from the GUI using the following steps:

Step 1: Open Settings on Debian 12 from desktop by clicking on any icon (Battery, Sound or Network). You can also open Settings from the application menu:

Step 2: Scroll down and navigate to the Users option:

Step 3: Click on the Unlock button to unlock the Add Users and Change Settings:

Step 4: Provide the administrator password, then click on the Authenticate button to unlock the settings:

Step 5: Now click on the Add User option:

Step 6: Write name, username, choose set password now option then set a strong password and click on the Add button to add the username to Debian 12:

Once completed, you will see that your username will be added to the Users section in Debian 12:

How to Delete User in Debian 12

If you have created a new user in Debian 12 and want to remove it, you can simply use the deluser command with sudo privileges and the required username:

sudo deluser username

Note: You must switch to another user if you are going to remove the username you currently logged in. To switch to other user on Debian 12, you can use the command:

su username

How to Delete a User from a Group in Debian 12

To delete a user from a group in Debian 12, use the following command:

sudo deluser username group_name

Conclusion

Creating and managing your user accounts on Debian 12 is useful for protecting the privacy of your data or other important applications. You can add a user in Debian 12 directly from the terminal using the adduser command or from GUI. Besides that, you can also add users to a specific group so that they will be able to perform similar responsibilities. Further, you can delete users from the system or a group using the deluser command; the complete guide for all the methods is provided in the above sections of this article. These methods will help you create users on Debian 12 and manage them wisely.

About the author

Awais Khan

I'm an Engineer and an academic researcher by profession. My interest for Raspberry Pi, embedded systems and blogging has brought me here to share my knowledge with others.