Ubuntu User Management Beginner’s Guide

Introduction to Linux User Management in Ubuntu

User management is one of the most important tasks in the corporate environment. Even one system uses several users not only to enter the system, but also to run various applications. An administrative role is also required for the Linux environment to manage multiple user accounts, their credentials, and system security. Basic commands must be known to the Linux administrator to manage these multiple user accounts (users and other subgroups).

In this guide, we will see the basic Linux commands that you might need in user management.

Create user account

As we all know, Linux is a multi-user operating system, so each user has his own account, which contains all the user data, including files and other information associated with this user. Data and information related to a specific user should not be accessible to other users. There is also the possibility that the same system is common to different users. Thus, the system administrator must know how to create and manage various user accounts in a Linux environment. In this tutorial, how you can create a user account using commands using the terminal:

Step 1: First of all, open a terminal by clicking on Ubuntu Launcher and find the terminal.

Step 2: Now click on the terminal and wait for the terminal to open.

Open terminal

Step 3: After opening the terminal, you will have the following screen:

Terminal prompt displayed

Step 4: Now enter the command:

sudo adduser username

where username will be the name of the user you want to create. After entering, enter the command by pressing the enter key. In this example, I create a user named demo1.

Create a user using the adduser command

Step 5: After execution, the system will request a password from the newly created user. Enter the password, confirm the password and press enter. The password you entered will not be displayed on the terminal screen, so do not worry about it.

Enter password for user

Step 6: After updating the password, the system will ask for basic user information. You can enter information related to this user, or simply press enter to insert the default value.

Enter user details

Step 7: As soon as you enter all the information, the system will confirm that all the entered information is correct or not. Press y to confirm. After confirmation, the user was created by the system.

Ubuntu Linux user has been successfully addedChange Password

In many situations, the user forgets his password, so the system administrator must reset the password for the user. Password resetting on Linux is pretty simple. Below are instructions for changing the password for a specific user.

Step 1: First of all, open a terminal by clicking on Ubuntu Launcher and find the terminal.

Open terminal to change user password

Step 2: Now click on the terminal and wait for the terminal to open.

Open terminal to change user password

Step 3: After opening the terminal, you will have the following screen:

Terminal command line

Step 4: Now enter the command

sudo passwd username

where username is the name of the user whose password you want to update. After entering, enter the command by pressing the enter key. In this example, I am modifying the password demo1.

Linux passwd team

Step 5: After execution, the system will ask the user for a new password. Enter the password, confirm the password and press enter. The password you entered will not be displayed on the terminal screen, so do not worry about it.

Ubuntu user passwd has been successfully changed

Your password has been successfully updated.

Delete user account

Sometimes in a shared environment where we have several users, but if one of them leaves a certain group, the administrator is obliged to delete old accounts from the system. Here’s what you should do if you need to delete an account.

Step 1: First of all, open a terminal by clicking on Ubuntu Launcher and find the terminal.

Find a terminal

Step 2: Now click on the terminal and wait for the terminal to open.

Run terminal application

Step 3: After opening the terminal, you will have the following screen:

Terminal prompt appears

Step 4: Now write the command

sudo userdel username

where the username is “demo1”. After you press enter, the user will be deleted.

Use userdel command to remove Linux user

Adding Users to Groups

One user can be assigned to a group, and this group is useful for applying any permission to the entire group, because it applies to all. Thus, it makes managing users much easier. In this tutorial, I’ll show you how you can add a user to the “sudo group”.

Step 1: First of all, open a terminal by clicking on Ubuntu Launcher and find the terminal.

Open terminal

Step 2: Now click on the terminal and wait for the terminal to open.

Run terminal application

Step 3: After opening the terminal, you will have the following screen:

The terminal is up and ready to enter.

Step 4: Now enter the command

sudo usermod –a –G examplegroup username

where the example group is the name of the group into which the user wants to be connected, and the username is the name of the user who wants to be added to the group. After entering, enter the command by pressing the enter key. In this example, the group is “sudo” and the user is “demo1”.

Add Linux user to group

The user will be added to this group.

Set Account Expiration Date

To automatically expire an account on Linux, we can set an expiration date after which the account will no longer be available for use.

Step 1: First of all, open a terminal by clicking on Ubuntu Launcher and find the terminal.

Find shell application

Step 2: Now click on the terminal and wait for the terminal to open.

Launch the Linux shell from the desktop

Step 3: After opening the terminal, you will have the following screen:

Linux shell window ready for input

Step 4: Now write the command:

sudo chage –E YYYY-MM-DD username

where the username is “demo1”. YYYY-MM-DD is the expiration date of the account.

Use linux chage command

As soon as you press enter, the account expiration date will be set and the account will expire after this date.

Change the default location of the user’s home directory

You can also change the default location of the user’s home directory by following these steps.

Step 1: First of all, open a terminal by clicking on Ubuntu Launcher and find the terminal.

Find a terminal program

Step 2: Now click on the terminal and wait for the terminal to open.

Run the program

Step 3: After opening the terminal, you will have the following screen:

Linux shell

Step 4: Now write the command

sudo usermod –d newuserhomedirectorypath –m username

where username is “demo1”, newuserhomedirectorypath is / home / demo1 / Desktop in our example.

Use Linux usermod command

After entering this command, the default location of the user’s home directory has changed.

Disabling Linux User Account

Any account can be disabled by the administrator. Below are some simple steps to do this.

Step 1: First of all, open a terminal by clicking on Ubuntu Launcher and find the terminal.

Get shell application

Step 2: Now click on the terminal and wait for the terminal to open.

Run shell application

Step 3: After opening the terminal, you will have the following screen:

Ubuntu Shell Ready

Step 4: Now write the command

sudo chage –E 0 username

where the username is “demo1”. As soon as you press enter, the account will be disabled for this particular user.

Use the chage command

If you want to enable a disconnected user, you need to run “sudo chage –E 1 username”. When you press Enter, the account will be reactivated for this user.

Enable user with chage command

Conclusion

In this lesson, we discussed the basic commands for creating, adding and deleting a user, then we discussed the steps for adding a user to a specific group. After that, we saw the steps to set the validity period of a specific account. We also saw a way to change the location of the user’s default directory. As a result, we saw a command to enable / disable a user account.

Ubuntu User Management Beginner’s Guide

Sidebar