This is the fifth article in this series of documents. I plan to cover the logon, hard disk, and periodic processes.
First, let's take a look at the login:
5.1 Login User
In the second article, we talked about the boot process of the Linux system. This is a transparent process for most users, but it is a visible operation for logon.
During the logon process, two important Linux Files are involved:/etc/passwd and/etc/shadow;
When the passwd file is used, the system identifies a list of users. The content consists of seven fields separated by colons. If you are interested, you can study by yourself. Here is just a general introduction.
This file can be viewed by anyone. Although encrypted, it can be cracked. To avoid such embarrassment, in all versions of Linux, users are allowed to hide the encrypted password in a separate file that not everyone can read. This file is called Shadow. In the system, only the root user can read the content of this file.
Compared with users, there is also the concept of user groups. This file is/etc/group. This file contains the Unix group name and the list of members in each group. This file also has four fields for your reference.
5.2 Add a user
Since users are involved, there must be some operations such as adding and deleting. in Linux, adding users can be divided into manual and command methods, however, at present, there are very few people who will use the manual method. Let's mention it here.
5.2.1 manual mode
To add a user in manual mode, follow these steps:
1. Edit the passwd and shadow files to define the user account;
2. Add the user to the/etc/group file;
3. Set an initial password;
4. Create the user's home directory and use the chown and CHMOD commands to change the attributes.
If you want to customize some commands and tools, you need to copy some startup files to the user's home directory. The Startup File is generally a hidden property. In Linux, It is a file name opened with dots.
Let's take a look at the common startup files. How many steps do I need to delete a user in manual mode?
1. Delete the user from the local user database;
2. Delete the user from the aliases file;
3. Delete the user's crontab file;
4. Terminate the user process;
5. Delete the user from the passwd, shadow, group, and gshadow files;
6. Delete the user's home directory;
5.2.2 command
It can be seen that manual operations are a disaster-like experience, not only may be wrong, but also may be missed. Therefore, we recommend that you use a comprehensive command method, that is, simple and safe.
Add User: useradd. This command can have many parameters.
Delete user: userdel;
And groupadd, groupmod, and groupdel commands that operate on user groups.
This series of articles may be concise and rarely detailed in some things. One is that you are too lazy to type one by one, and the other is mainly to give yourself a general outline, if you forget it later, you can go back and flip it. If you cannot remember the details, you can check the manual.
To be continued .....