How to Add and Delete Users on Debian 12?


Adding and removing users is essential when setting up a new Debian 12 system. Debian, like other Linux distributions, is a multi-user operating system. It allows multiple users to interact with the system simultaneously by providing multi-user environments, different permissions, and many more. So, authorized users (only) can access protected files and perform specific actions.

By considering its importance, this guide will demonstrate the procedure of adding as well as removing users (system and regular) on Debian 12. Users can have varying settings and permissions for CLI and GUI applications.

How to Add and Delete Users on Debian 12?

To manage users in Debian 12, users can add or delete them using the command line. Let’s walk through the steps:

Let’s start with adding users to the Debian system.

Add Users on Debian 12

For creating a new user account, two command-line tools can be used: adduser and useradd. The “adduser” is the recommended one. So, adding users in Debian 12 involves both system users and regular users. Let’s break it down:

Add System User on Debian 12

System users are typically created during the installation process and are used to run system processes. To add a system user, use the adduser command with sudo privileges and specify the desired username such as “roger”:

sudo adduser roger

It prompts users to set a password and provides optional information. Once done, the user will be created in the “users” group. It creates the new user’s home directory.

Verification

For confirmation, users can display the “users” group members via the below command:

grep 'users' /etc/group

Note: By default, members of the sudo group have administrative rights. For the newly created user, add to the sudo group for root privileges:

sudo usermod -aG sudo <user_name>

Add Regular Users on Debian 12

Regular users can interact with Debian 12, and have their own user identity (UID), and group identity (GID). They also have their directories and permissions.

To add a regular user, use the useradd command with the -G option to specify the group:

sudo useradd -G linuxgenie john

This command adds the user “john” to the “linuxgenie” group.

Note: If users do not have any existing group, they can create a group via the below command:

sudo addgroup linuxgenie

Verification

For confirmation, users can check the membership of the group via the “grep” command as below:

grep 'linuxgenie' /etc/group

Adding Users via GUI

Alternatively, you can use the graphical interface. For this, open the “Settings” application. Navigate to the “Users” section. Click “Add User” and provide the necessary details:

Now, enter your name and username. Then, switch on the “Administrator” (toggle) button to access the sudo privileges to the added user. Finally, hit the “Add” button:

Users can choose the appropriate method based on their preference, whether it’s the terminal or the GUI to manage users in Debian 12.

Delete/Remove Users on Debian 12

If a user is no longer required, delete it via userdel or deluser. The deluser is recommended as it’s more user-friendly. Let’s follow the stated steps to delete a user:

Prerequisite Step: Adding a User

To add a system user, use the adduser command with sudo privileges and specify the desired username:

sudo adduser <username>

It requires setting a password for the new user (created one). Follow the above adding user instructions to complete the process.

Deleting a System User on Debian 12

To delete a system user, use the deluser command (without removing their files). For instance, remove the already added user “roger”:

sudo deluser roger

Verification

For confirmation, use the “grep” command by specifying the (system users) group directory:

grep 'users' /etc/group

In this way, “roger” is no longer part of the system users group.

Deleting a Regular User on Debian 12

To delete a regular user, use the same deluser command. For instance, delete the user “john” as below:

sudo deluser john

Optional: Remove User’s Home Directory

To remove the user’s directory (home), execute the “remove-home” option/utility as below:

sudo deluser --remove-home <user_name>

Remove Users via GUI

To remove users via the graphical user interface (GUI) on Debian 12, click on the “Settings” icon to open the system settings. Then, hit the “Users” option and select the user you want to remove such as “minhal”:

After that, push the “Remove User” button to delete the user. Finally, confirm whether to keep its files or not based on needs:

Note: If some issue, click the “Unlock” button to authenticate as an administrator.

Remember, managing user access and privileges is important for maintaining an efficient as well as secure Debian system.

Conclusion

To add a new user on Debian 12, use the adduser command by following the syntax “sudo adduser <user_name>”. In addition, the “sudo” group members have administrative rights (by default). To grant privileges to the newly created user, add them to the sudo group via the “sudo usermod -aG sudo <user_name>” syntax. To delete a user on Debian 12 without removing their files, execute the “sudo deluser <user_name>” command. This article has completed different ways to add as well as delete users on Debian 12.

Print Friendly, PDF & Email
Categories