The last article introduced you to the knowledge of Linux accounts, and then I will tell you about the knowledge of account management. To put it simply, it is nothing more than adding and deleting accounts.
1. Adding and deleting
1.1. How to add a user
When adding a user in Linux, the "useradd" command is used. When using this command, you can create it directly, and the system will automatically assign related parameters, or you can add them with parameters , The following figure is an example:
In the above figure, the main scene is: First, I use "cat /etc/passwd" to view the relevant information of all users, I see that the user group of the user'chao' is'chao' , So I performed two steps. The first step is to directly use the useradd LI command to create a new user LI, and then use the useradd LI2 -u 1003 -g chao command to create the user LI2. Through comparison, we can find that the first This command will create a user group name that is the same as the user name for a new user by default, and the second command assigns an existing user group name to the new user so that it has the permissions of the user group.
Note: The UID mentioned above, here is an extension. In the above figure, you can see that the UID of root is 0. When UID is 0, it means that this account is the system administrator account, so if you want other When the account also has root privileges, you only need to set the UID to 0, which is generally not recommended. At the same time, it is also stipulated that UID 1~999 are system accounts, such as the bin and daemon accounts above. In fact, except for the 0 account, these accounts do not have much difference in characteristics. Generally speaking, 1 to 200 are system accounts created by the LINUX release, and the part 201 to 999 is generally reserved for users when they have system account requirements. The last thing to say is 1000 ~ 60000, this part of the account is for general users. As shown in the figure below: The UIDs of the newly created users LI and LI2 are both after 1000.
1.2 Delete user
When deleting a user, you only need to use the "userdel" command. One thing to note, if I want to delete the user'gaochao', because the user'gaochao' belonged to the user group'gaochao' when I created it before, if this time There are no other users in this user group except for the user "gaochao". When the delete operation is executed, the user group "gaochao" will also be deleted. The example is as follows;
2. Password
2.1
Set a password Why should I set a password? Because the newly added account will be locked and cannot be used without setting a password. The command used to set the password is "passwd". The picture below shows that the password of other users can be modified in the root user environment. Just enter and confirm it.
The following picture shows the operation when the current user password is modified under the current user. The difference from the first one is that this modification method requires the current password to be entered. It is especially reminded to use this method carefully under the root user. Otherwise, the password of the root user will be changed.
2.2 Password attribute setting
In addition to setting the password, many times we also need to set the password attribute. For example, if the password is to be modified within 60 days, it will expire after 10 days. How to set it? At this time, you need to execute the command with parameters. Let's take a look at an example:
in daily operations, we use more passwd commands, in addition to a "chage" command that can achieve the above functions, and can be modified in more detail. We only explain its most excellent (personally think) features here: [When users log in for the first time, they are forced to change their passwords before they can use system resources]
As shown in the figure below, when they log in for the first time You need to change your password. Everyone has encountered this situation. During class, the teacher will assign an account with the same password to everyone, and then you can change your password after logging in.
3.
User group The operation of user group is similar to that of user, the operation command to add user group is "groupadd"
The command to delete a user group is "groupdel"
. I will talk about the content of account management first, and continue tomorrow.
Linux account management (1)
Guess you like
Origin blog.csdn.net/Gao068465/article/details/106639603
Recommended
Ranking