Jump to content

How to Add a User in Debian 12


Linux Hint

Recommended Posts

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

word-image-407468-1.png

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:

word-image-407468-2.png

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:

word-image-407468-3.png

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

word-image-407468-4.png

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

word-image-407468-6.png

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

word-image-407468-7.png

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:

word-image-407468-8.png

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:

word-image-407468-9.png

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

word-image-407468-10.png

You can then verify the group using the following command:

grep group_name /etc/group

word-image-407468-11.png

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

word-image-407468-13.png

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:

word-image-407468-15.png

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

word-image-407468-16.png

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

word-image-407468-17.png

Step 5: Now click on the Add User option:

word-image-407468-18.png

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:

word-image-407468-19.png

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

word-image-407468-20.png

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

word-image-407468-21.png

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

word-image-407468-22.png

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.

View the full article

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...