The last time I talked about some common user and group operation commands, I also need to know a few other knowledge points, I will share my learning experiences one by one. 1. check the user status. sometimes we can use sudopasswd-S to check the user status.
I talked about some common user and group Operation Commands last time. in addition to those commands, I also need to master several knowledge points. here I will share my learning experiences one by one.
1. view the user status
Sometimes we can use the sudo passwd-S user name if we want to view the user's status. Although the command is the same, the results of different linux operating systems are different, for example, if the status of ubuntu is L, it indicates locking, P indicates normal, and NP indicates that the password is cleared, as shown below:
2. lock the user
Locking a user means that the user cannot log on. The last time I mentioned a method to modify the configuration file, this method is not recommended for many times, because if you accidentally mess up other places, the consequences will be serious.
You can also use the passwd-l user name to lock the user. This operation also requires the root permission, as shown below:
After the user is locked, the user cannot log on successfully even if the user has entered the correct user name and password, as shown below:
3. unlock a user
The password for unlocking a user is the sudo passwd-u user name. The operation is as follows:
After unlocking, you can see that the user can log on.
4. delete the user's logon password
For redhat, a user can log on successfully if the password is deleted, but for ubuntu, if the user password is deleted, the user cannot log on, to delete a user password, follow these steps:
5. Switch users
Switching users seems to be using a lot of passwords. the password is su's other user names, as shown below:
6. view the user information logged on before the ticket
7. complete user information
8. add a user to another group
In linux, users are allowed to belong to multiple groups, which is conducive to authorization of some operations. Next let's see how to add liming to other groups. the command is sudo gpasswd-a username and other groups, as shown below:
This operation is different from the usermod-g group name. The operation shown is to divide the user into the original group of other groups, the usermod-g group name, right? the user is assigned to another group, which is similar to leaving the original group.
Run the following command to check which groups liming belongs:
In this way, liming can switch between the two groups. the command for switching the group is the newgrp group name. this command must be used after logon, but does not require the root permission, after switching the user group, if you want to exit, you should first exit the current group and enter exit after the main group.
9. run the id and finger commands to view user information.
Id username ---- view rough information
Finger username ----- view detailed information such as phone and email
Note that if linux uses ubuntu, use sudo apt-get install finger to install software that supports the finger command.
Linux is really boring to learn, except for commands or commands, but as long as there is firm information, it is no problem to learn linux well.