Home // Managing Users on Ubuntu: A Comprehensive Guide

Managing Users on Ubuntu: A Comprehensive Guide

0 15 minutes read
| Published on: July 11, 2023 | Last updated on: September 1, 2023

Introduction to User Management on Ubuntu

Managing users effectively is a crucial part of maintaining a secure and efficient Ubuntu system. But why exactly is user management so important on Ubuntu?

Why User Management is Crucial on Ubuntu

User management allows you to control who has access to your system and what they can do with it. By assigning specific permissions and roles, you ensure that users can perform their tasks without compromising the security or stability of the system.

Understanding the Basics of User Management

Before we delve deeper into the how-tos of user management, let’s first understand some basic concepts.

Distinguishing Between Root and Standard Users

In Ubuntu, there are two types of users – the Root and the Standard users. The Root user, also known as the ‘superuser’, has administrative access to the system, while Standard users have limited permissions. Understanding the distinction is vital to ensure the correct assignment of roles and prevent unauthorized access.

Understanding Permissions and Groups

Every user belongs to at least one group, which defines what they can or cannot do on the system. Permissions are attributes assigned to files and directories, dictating how the system handles interactions with users.

Getting Started: How to Add Users on Ubuntu

There are two ways you can add users on Ubuntu: through terminal commands and via the graphical interface.

Adding Users Through Terminal Commands

When you need to add a new user on Ubuntu, doing it through the terminal might be your fastest option, especially if you’re working on a remote server. Here’s a more detailed step-by-step guide:

  1. Open the Terminal: You can do this by searching for “Terminal” in your applications or by using the keyboard shortcut Ctrl+Alt+T.
  2. Use the ‘adduser’ Command: Type in sudo adduser [username], where [username] is the name you want to give the new user. Remember, usernames should be lowercase and without spaces for compatibility. Press Enter after typing the command. The ‘sudo’ prefix is necessary because this is an administrative action, and it prompts for your password to ensure authorized access. sudo adduser john
  3. Enter Your Password: If you invoked the command using ‘sudo’, you’d be prompted to enter your password to proceed. This is the password of the account you’re currently logged into, not the new user’s password.
  4. Set the New User’s Password: After providing your password, you’ll be prompted to set a password for the new user. Enter a strong password, then press Enter. You’ll be asked to retype the password for verification.
  5. Provide User Information: The ‘adduser’ command will also ask for additional information such as the full name of the user, room number, work phone, home phone, and other. This information is optional, and you can just press Enter to skip each of these if you prefer.
  6. Confirm the Information: Finally, you’ll be asked to confirm that the information provided is correct. If it is, type ‘Y’ and then press Enter. If it’s not, type ‘N’ and press Enter. If you typed ‘N’, you’d have to repeat the process from step 4.

Your new user is now created and ready to use. They’ll have their home directory under /home/[username] where they can store personal files. They’ll also be able to use the ‘sudo’ command if they need to perform actions that require administrative access, like installing new software.

Here’s an example of what adding a new user might look like:

$ sudo adduser john
Adding user `john' ...
Adding new group `john' (1002) ...
Adding new user `john' (1002) with group `john' ...
Creating home directory `/home/john' ...
Copying files from `/etc/skel' ...
Enter new UNIX password: ****
Retype new UNIX password: ****
passwd: password updated successfully
Changing the user information for john
Enter the new value, or press ENTER for the default
    Full Name []: John Doe
    Room Number []: 
    Work Phone []: 
    Home Phone []: 
    Other []: 
Is the information correct? [Y/n] Y

Adding Users Through the Graphical Interface

Alternatively, you can use the User Accounts tool in the System Settings. Click ‘Unlock’ and enter your password, then click ‘+’, select the account type, and fill in the necessary information.

Modifying and Deleting Users

Ubuntu’s flexibility shines when it comes to user management. Not only can you add new users, but the system provides you with the tools necessary to modify user information, permissions, and even delete users when they’re no longer needed. Let’s delve into these capabilities in more detail.

Modifying User Information and Permissions

Modifying a user’s information and permissions in Ubuntu is a common task, especially in dynamic environments where user roles can change frequently. For such tasks, the usermod command is a powerful tool.

Changing a User’s Login Name

Suppose you’ve added a new user, but later you realize that the username needs to be changed. Ubuntu provides a simple way to do this using the usermod command:

sudo usermod -l new_username old_username

In this command, old_username is the current username that you want to change, and new_username is the new name you want to assign. After running this command, the user will have to use the new username to log in to the system.

Changing a User’s Home Directory

Another common task is to change a user’s home directory. This is particularly useful when managing disk spaces or when the user’s role requires them to shift to a different directory. Here’s how you can do this:

sudo usermod -d /new/home/dir -m username

The -d option followed by the /new/home/dir specifies the new home directory for the user. The -m option is used to move the contents of the user’s current home directory to the new home directory. username is the name of the user.

Modifying User Group Affiliations

A user’s permissions on the system are often tied to the groups they belong to. When a user’s permissions need to be changed, this can often be accomplished by adding or removing the user from certain groups. For example, to add a user to a new group, you would use the following command:

sudo usermod -aG groupname username

In this command, groupname is the name of the group you want to add the user to, and username is the name of the user. The -aG option tells usermod to add the user to the supplementary group(s) mentioned.

Remember that the changes made using the usermod command will take effect the next time the user logs in, so you might need to ask them to log out and log back in if the changes need to be applied immediately.

Deleting Users

There are situations when a user account becomes redundant or the user no longer requires access to the Ubuntu system. In such cases, you can use Ubuntu’s built-in commands to delete the user and manage their associated files.

Deleting Users Using deluser Command

Ubuntu’s deluser command offers a straightforward way to remove a user from the system. The syntax for this command is as follows:

sudo deluser username

Here, replace username with the name of the user you wish to delete. This command will effectively remove the user from the system, but it will leave the user’s home directory and personal files intact. This feature is beneficial when you might need to recover files or data associated with the user.

Deleting Users Along with Their Home Directory

In some cases, you might want to delete not only the user but also all their associated files, including their home directory and mail spool. Ubuntu provides an option for this:

sudo deluser --remove-home username

In this command, replace username with the user’s name you want to delete. The --remove-home option tells the system to delete the user’s home directory and all its contents. Be cautious while using this option as it will permanently remove all the user’s files and cannot be undone.

Managing User Files Post Deletion

After deleting a user, especially when keeping their home directory intact, you might want to review the files they left behind. These files can be found in the deleted user’s home directory, typically /home/username. You can move these files to another location, back them up, or remove them as needed.

Deleting Users via Graphical Interface

While the terminal offers robust control and flexibility, some might prefer using a graphical interface. You can achieve the same user deletion functionality via the User Accounts tool found in Ubuntu’s System Settings. This tool offers a user-friendly way to manage users, including modifying their information or deleting them.

Managing Groups on Ubuntu

Group management on Ubuntu is a critical aspect of system administration. A group is a collection of users, simplifying permission management by allowing you to assign permissions to many users at once. Let’s delve deeper into creating and deleting groups, as well as adding and removing users from these groups.

Creating and Deleting Groups

The ability to create and delete groups is fundamental in Ubuntu. Groups help you manage users with similar roles or permissions in a more organized manner.

Creating Groups

To create a new group, you’ll use the groupadd command followed by the desired group name. Let’s say you want to create a group called “developers”:

sudo groupadd developers

This command creates a new group named “developers”. The sudo prefix is necessary because creating a new group is a system operation and requires superuser privileges.

Deleting Groups

When a group is no longer needed, you can delete it using the groupdel command, followed by the group’s name. Be cautious as this action can’t be undone. To delete the “developers” group:

sudo groupdel developers

After running this command, the “developers” group will be removed from your system.

Adding and Removing Users from Groups

Once your groups are set up, you’ll often need to add users to them or remove users from them. The usermod command, combined with the appropriate options, will enable you to do this.

Adding Users to Groups

To add a user to a group, you can use the usermod command with the -aG options. The -a option tells usermod to append the user to the supplementary groups mentioned. The -G option is followed by the name of the group. Let’s say you want to add a user called “john” to the “developers” group:

sudo usermod -aG developers john

After running this command, the user “john” will be a member of the “developers” group.

Removing Users from Groups

To remove a user from a group, the gpasswd command is generally preferred. The -d option followed by the user’s name and the group’s name will remove the user from the group. If you wanted to remove “john” from the “developers” group:

sudo gpasswd -d john developers

After running this command, the user “john” will no longer be a member of the “developers” group.

Understanding how to manage groups in Ubuntu is essential for efficient user and permission management. By following these steps, you’ll be well-equipped to handle user groupings in your Ubuntu system. Remember, inappropriate group management can affect system security and operations, so always be cautious.


Effective user management on Ubuntu not only helps in maintaining a secure and stable system but also increases productivity by ensuring users have the appropriate access and permissions. It’s a powerful tool in the hands of system administrators and one that should not be overlooked.


  1. How do I list all users in Ubuntu?
    You can list all users in Ubuntu using the `getent` command in the terminal.
  1. Can I change a user’s password as a Root user?
    Yes, as a Root user, you can change any user’s password. Use the passwd command followed by the username in the terminal.
  2. What is the difference between adduser and useradd?
    adduser is a more user-friendly command that automatically sets up a home directory, copies skeletal files, and allows for custom scripts. useradd is a lower level utility often used by scripts and admins, it simply creates a new user record in the system files.
  3. What does a group do in Ubuntu?
    A group in Ubuntu is a mechanism to manage a set of privileges such as reading, writing, or executing permission for a given resource that can be shared among the users within the group.
  4. How can I see which groups a user belongs to?
    You can see which groups a user belongs to by using the groups command followed by the username in the terminal.


Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

Copyright @2022-2024 All Right Reserved – PCPlanet

We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. You understand and give your consent that your IP address and browser information might be processed by the security plugins installed on this site. By clicking “Accept”, you consent to the use of ALL the cookies.
Accept Read More

Privacy & Cookies Policy