Administrarea utilizatorilor

Ubuntu User Management

Ubuntu User Management

Linux administrators often need to manage users and groups in a Linux/Ubuntu System. User management, access control, and Group management are the basic yet the most important need. In this post, we will learn about

In this post, we will perform each of the above-mentioned tasks through the terminal.

Creation of a User

We can add a user in the Ubuntu Operating System through GUI or from the terminal. We can either use the simple “adduser” command to add a user or the “adduser -system” command to add a system user.

To create a new system user,

$ sudo adduser --system linuxuser2

To create a simple user,

$ sudo adduser linuxuser1

After running the above command, it will ask you to set the new password for the newly created user twice.

It will then ask you to provide the username, room number, phone number of your work and home, and others. Provide the desired details and hit “Enter”

After providing the details, it will ask you either the provided information is correct or not. Press “y” to continue and press Enter if the information is correct.

List all Users

Now, if you want to list all Ubuntu users in the terminal, you can type the following command.

$ cut --delimiter=: --fields=1 /etc/passwd

It will list all the users of the Ubuntu System.

Change Password of a User

If you want to change any user's password, you first have to log in with that specific username. For example, for changing the password of linuxuser1,

$ su - linuxuser1

After running the above command, it will ask you to enter the password of that user, type in the password, and hit “Enter”.

You can see that the username is changed.

Now, run the “passwd” command,

Enter your previous password first, and then provide the new password twice and hit Enter. If both of the new passwords will be the same, then the password will be changed successfully.

Creation of a Group

You can create or add a Group in any Linux based operating system using the “addgroup” command.

$ sudo addgroup linuxgroup1

As you can see that the “linuxgroup1” is created successfully.

List all the groups

Now, If you want to list out all the groups that exist in the Ubuntu Operating system, run the command given below

$ cut --delimiter=: --fields=1 /etc/group

It will list out all the existing groups of the operating system.

Addition of a User in a Group

The users can be grouped as well in Ubuntu. We can add a user to the group by providing the group name and username to the “usermod” command with the -aG flags like this,

$ sudo usermod -aG linuxgroup1 linuxuser1

The user “linuxuser1” will be added to the “linuxgroup1” group.

Show Group of a User

To see the user's group, type the “groups” command in the terminal and hit Enter. It will show the groups of the user. You first have to log in with that specified user and then run the “groups” command.

$ su - linuxuser1

$ groups

As you can see that the “linuxgroup1” is listed as the group of “linuxuser1”.

List all the Users in a single Group

To list all the users of any group, run the “cat”, “cut”, and “grep” command with the following parameters.

$ cat /etc/group | cut --delimiter=: --fields=1,4 | grep GROUPNAME

Make sure to replace the group name with your desired group name. For example, “linuxgroup1”

You can see that the users in “linuxgroup1” are listed.

Deletion of a User from a Group

If you want to remove a user from any group. You can do so by typing the user name and group name followed by the “deluser” command.

$ sudo deluser linuxuser1 linuxgroup1

You can see that the user is removed from the “linuxgroup1” group.

Deletion of a User

If you want to delete a user from the Operating system. You can simply delete it by running the “deluser” command with the user name

$ sudo deluser linuxuser1

If you want to delete the user's home directory as well, use the “-remove-home” flag with the “deluser” command like this

$ sudo deluser --remove-home linuxuser1

And now, if we list the “/home” directory, there will be no more home directory of the “linuxuser1” user.

Deletion of a Group

To remove the group from the operating system, run the “delgroup” command with the group name like this

$ sudo delgroup linuxgroup1

The group is deleted successfully.

Wrap Up

Managing the users is a very important task that Linux administrators perform. In Linux based distributions, we can easily create new users and manage them. This article describes user management on the Linux based system in detail.

Tutorial Shadow of the Tomb Raider pentru Linux
Shadow of the Tomb Raider este a douăsprezecea completare a seriei Tomb Raider - o franciză de jocuri de acțiune-aventură creată de Eidos Montreal. Jo...
Cum se mărește FPS în Linux?
FPS înseamnă Cadre pe secundă. Sarcina FPS este de a măsura rata de cadre în redările video sau în performanțele jocului. În cuvinte simple, numărul d...
Cele mai bune jocuri Oculus App Lab
Dacă sunteți proprietarul căștilor Oculus, atunci trebuie să fiți informați despre încărcarea laterală. Încărcarea laterală este procesul de instalare...