The creation and deletion of users is a fundamental skill that every Linux user should master. Whether you work in a graphical interface or prefer the terminal – managing users is essential for the security and organization of your system. In this guide, you will learn how to create new users in Ubuntu and delete existing users.

Key Insights

  • You can create users via the graphical user interface or the terminal.
  • The command adduser is recommended for creating new users.
  • To delete users, you use the command deluser.
  • Administrator rights are required to execute these commands.

Step-by-Step Guide

Create New User

To create a new user, you have two options: the graphical user interface or the terminal. In this guide, we focus on the terminal approach, as it is also suitable for servers without a graphical interface.

Start the terminal and enter the command sudo adduser {username}. In this example, we are using "Kai" as the username. The command looks like this:

User management in Linux: Creating and deleting users

After you press Enter, you will be prompted to enter your administrator password. After entering the password, you will be asked for the password for the new user. Choose a secure password and confirm it.

User management under Linux: Creating and deleting users

Next, you will be asked for complete information. This information is optional and can be skipped. For example, you can simply press Enter to skip the input.

User management in Linux: Creating and deleting users

Once you have completed the input, the user "Kai" is now created. Now run the command su - kai or login kai to log in with the new user. Enter the previously chosen password to access the new user's desktop.

User Management in Linux: Creating and Deleting Users

Delete User

To delete a user, use the command sudo deluser {username}. In this case, we will delete "Kai". The command is:

User management in Linux: Creating and deleting users

Entering this command gives you the option to remove the user. Note that at this point, no confirmation prompt appears; this step emphasizes the importance of knowing exactly what you are doing. Confirm the command with Enter.

User management in Linux: Creating and deleting users

If you want to remove the user from groups at the same time, the deluser command can be used with the appropriate group name.

Add User to a Group

If you want to assign a group at the time of creating a user, you can use the following command:

User management in Linux: Creating and deleting users

With sudo adduser {username} {groupname}, where "Kai" is the user and "Rene" is the group, the command adds user Kai to group Rene.

User management in Linux: Creating and deleting users

With these commands, you have efficient control over user management in your Linux system.

Summary – User Management in Linux: Create and Delete New Users

In this guide, you learned how to add new users and delete existing users in a simple and efficient way. You can use both the graphical user interface and terminal commands, which offer great flexibility, especially in headless environments.

Frequently Asked Questions

How do I create a new user in the graphical interface?You go to the settings and then to Users. There you can create new users.

What do I do if I want to delete the user?Use the command sudo deluser {username} to remove the user.

Do I need administrator rights to create a user?Yes, you need administrator rights to create or delete users.

Can I also assign user groups?Yes, when creating a user, you can immediately assign them to a group.

How can I view existing users?Use the command cat /etc/passwd to get a list of all users.