【Manage Users and Groups in Linux】Step by Step Guide ▷ 2022

Manage users and groups in Linux It will allow you to keep the information you store on your computer safe. It will also make the OS work correctly. This is because of the limits you will be putting on the operators.

For this reason, It is important to know how to manage users and groups in , but first you need to understand the difference between these terms.

This information can be found in the paragraphs of this article. Also, we will talk about which are the most important files and you will know the step by step that you must do to carry out a correct management.

Why is it important to manage users and groups in Linux?

Given the linux It is a multi-user OS, there must be a logical order for the proper use of resources and correct operation. From this it arises that each user, or group, must have their space and their role within the system. So each user will be able to execute actions within the OS without jeopardizing its operation and the data of third parties.

You must not forget that in a multi-user OS, in order for it to be well managed and to protect the data, an account (consisting of the password and the user ID) must be granted to generate a specific path within Linux. In this path, all the user’s files will be safely stored, including their emails and their profile, thus preventing the intrusion of people outside the environment. Only the main administrator, or user root, You can set which files each user is allowed to execute or read.

Furthermore, thanks to Super user is established what modifications are allowed to makefor example, change your password when necessary or read a . Having these limits is a great long-term benefit for data protection. With using a UID or GID (identification number for users and groups) the administrator can even know if a file that should not be manipulated has been altered.

What are the differences between users and groups in this OS?

An important part of good management is to clearly understand what is a group and what is a user in Linux. As a user you will have some limit (physical or virtual) to access the OS. Said access is related to the username and password assigned by the main administrator. Many people think that a user account It is only intended for the use of natural persons. However, some of this type also grant access to certain programs or virtual applications.

Secondly, groups within the OS work to bring together a set of users for the same purpose. No matter what role they play within a company or organization, the manager will bring them together if they have a common goal. The latter means that a user can belong to more than one group, but they must always be part of a main group that identifies them.

See also  【IMPROVE Wi-Fi Network Security】▷ Step-by-Step Guide ▷ 2022

Files related to users and groups in Linux What are the ones I should know?

Among the vast expanse of files in Linux there are special files that facilitate the management of groups and users.

We show you the most important ones below:

/etc/passwd

If you use the /etc/passwd file you will see all user account data.

These have online contents including:

  • Name of the user.
  • The password encrypted.
  • The UID which refers to the user’s identification number.
  • the gid or identification number of the group to which the user belongs.
  • The comments that complement the information or finger of the user.
  • the directory starting point of a certain ID.
  • the shell that is used by each participant.

Each of these fields can be differentiated by a colon “:”. Typically, you will see the encrypted key symbolized by a “X” for standard users. If you want to expand this information you will have to go to the file “/etc/shadow/”.

/etc/group

It is a file that stores information concerning all groups in the system.

Visually it will show you a series of lines that contain:

  • Name of the group.
  • The key encrypted if you have it.
  • the gid or group identification number.
  • Name of all the users that make up the group.

All these data will be separated by colons “:”. And for usernames, these will be differentiated by commas. “,”. If you want to view them You must have root privileges on the OS.

/etc/shadow

In the File /etc/shadow I know saves information related to user and group passwords, mentioned in the other file /etc/passwd. To be able to work with this tool you must have root access.

There you will find:

  • The login or username.
  • The key encrypted.
  • Time What happened since the last password change?
  • The days remaining to change the password.
  • maximum time in which the OS will give the user to modify the key.
  • a time notice in which the user will be alerted to change the password.
  • Weather of expiration.

if in the key space you find an exclamation mark “!” It means that it is a blocked account. It can also be an account that has not yet been assigned a key class.

User and group management commands, which are the most important?

We will show you in this section the most important commands that you should use to carry out a correct management of users and groups in Linux.

These are:

  • sudo: is the primary command for making any changes as administrator, superuser, or root user. It means “Superuser does” and should almost always precede any other arguments that require special permissions.
  • useradd: makes it easy to create a new user from the console. You will also be able to use in the same way adduser, depending on OS configuration. On FreeBSD, for example, it includes a wizard that simplifies management.
  • usermod: provides an environment for editing user data. For example, your name, your group, block the account and modify the maximum time to renew the password, among others.
  • userdel: If you use this command you will easily delete a user, whether they are logged in or not in the system.
  • groupadd: is similar to useradd. With this argument you will create one or more new groups.
  • groupdel: it is used to eradicate a group that does not have users as the main group within it.
  • group mod: facilitates the management of changes or modifications within a certain group, works the same as usermod with users.
  • password: This command allows the creation or subsequent change of the password of a certain user.
  • id: if what you want is to see the identification number of a user or group you will have to use this argument.
  • fingers: this argument is perfect for displaying the data of a given user. It will show you the login, his name in real life and the time he logged in, among other things.
  • newusers: Generate multiple new users at once in multi-user mode.
  • chpaswd: Allows you to determine passwords or keys in multi-user mode.
See also  【 CREATE ACCOUNT in HABBO 】▷ Step by Step Guide ▷ 2022

Learn step by step how to seamlessly manage Linux users

Next, you will find the step by step that you must carry out to manage the users of the Linux OS:

Create a user

For create a user you will have to access the terminal and enter the argument sudo (as root user) and then useradd in front of the new username.

The command will be similar to:

  • sudo useradd internetstepstep

If you want to assign a main group to said user you will have to use useradd -g, preceded by the group name and then the username. This is done instead of using useradd.

Therefore, the command will be:

  • sudo useradd -g namegroup internetstepstep

You will also be able to create a directory in /home with the username. For this case, you will have to use sudo, useradd, username, and -m. Then you will have to create the password. For this you will have to use the command passwd which will also serve to modify it in the future.

The command will remain:

  • sudo passwd , after that you will have to write the key twice for confirmation.

Delete users and groups

thanks to the command userdel you will be able delete a user placing it followed by the corresponding name and its primary group.

For example:

  • sudo internet user step by step namegroup

In this case the working directory and internal files will not be removed. If you want these to be permanently deleted, you must write userdel -r. Always preceded by sudo and before the name.

See also  【 SOLUTION 】Ethernet Does Not Have a Valid IP Configuration ▷ 2022

You will end up with this syntax:

  • sudo userdel -r internetstepstep

In this way you are going to delete directories, files and even their emails. When you need to delete groups, you will have to enter the terminal groupdel, after sudo and before the group name.

An example of this is:

Remember that this group will only disappear if you do not have users using the group as primary.

Change a user owner of a file

Using the argument chown, preceded by sudo, you are going to change the owner of a given directory or file. That is, you will change a user who owns a file if you place sweat chown, then the new name of the owner user and finally the title of the corresponding file.

The command syntax will be:

  • sudo chown ipap , where Pap would be the new owner of the file .

Edit users and groups

After you have created some users you may want to edit your detailsfor that there is the argument usermod. That is, if you want to enter a new comment for a user, you will have to use the argument sudo usermod -c and post the comment.

Giving way to:

  • sudo usermod -c comments ipap

As in all commands there are variables, for example, with -l you block an account, while with -g you will refresh the primary group the user is in. if we use -s either -d you will change the shell or the working directory, respectively. You must not forget that all these commands must be preceded by sudo usermod. While, to modify data of a certain group you can use the command groupmod. Keep in mind that with groupmod –n you will change the name of the group and with groupmod –g you will modify his GID.

You will have a result similar to:

  • sudo groupmod -n namegroupnew, to renew your name.
  • sudo groupmod -g gidgroupnew to change your GID.
Loading Facebook Comments ...
Loading Disqus Comments ...