Anatomy of a/etc/passwd file
File format:
Root:x:0:0:root:/root:/bin/bash
User name: Password bit: uid:gid[default group ID]: annotative Description: Host directory: shell[7 section]
Linux User categories:
Super User (root,uid=0)
Normal User (uid=500~60000) #最大值是可以更改的
Pseudo-user/special user (uid=1~499)
#因此, after changing the UID of a user's user to 0, it becomes a super user
pseudo-User features
1, pseudo-user and system and program services related
such as: Bin, daemon, shutdown, halt, and so on, any Linux system default contains these pseudo-users
such as: Mail, news, games, Apache, FTP, MySQL and sshd, etc., related to the Linux system process of pseudo-users
Like MySQL is automatically added to the configuration file at the time of installation.
2, pseudo-users usually do not need or can not log on the system, so the pseudo-user mechanism to ensure the security of the system
3, can not host directory
User Groups
1. Each user belongs to at least one user group
"In managing the system, each user should be subordinate to their own group, so that each user will" do their own thing ", have their own unique permissions, not" chaos ""
2. Each user group can include multiple users, one user can belong to multiple groups at the same time
3. users in the same group enjoy the permissions shared by the group
4. If you do not specify a user group when creating a user, the system creates a group with the same user name and joins that user to the group
Other Notes
Annotative Description # For example, information such as the user's full name, the department that the user belongs to, and so on, when adding the user is, it is best to write a description that will later differentiate the user's role
Host Directory # The default directory after the user logs on to the system
Command interpreter # User-used shell, default to bash
Anatomy of a /etc/shadow file
File format:
Root:$1$0hzunscv$urjus1mrpjafavcmyo0bi1:15957:0:99999:7:::
User name: Encrypted password: Last modified: Minimum time interval [0 for unrestricted]: Maximum time interval: Warning Time: Account idle time: Expiry time: Flag "generally not used"
Additional Information Description:
If the password bit is emptied, the password is no longer required to log on to the user.
Minimum time interval: two minimum number of days between password changes
Maximum time interval: The maximum number of days the password remains valid, forcing the user to change the password
"View/etc/shadow file Help information: Man 5 Shadow"
/etc/shadow file Permissions
linux password mechanism
Write back the password back: pwunconv# commercial UNIX does not provide this tool
The/etc/shadow file does not exist at this time
Password conversion: Pwconv
And now/etc/shadow is back.
That is-the password conversion action is always performed automatically whenever the system creates a password.
"Verify the/etc/passwd file when validating the user name, verify the password when verifying:/etc/shadow"
"View root password information grep root/etc/passwd/etc/shadow"
Brief analysis of/etc/login.defs
User Login Default Information
create_homeyes# Create a host directory while creating a user
UMASK 077# Default User permissions to create files or directories
"The various options are described in more detail in the statement above."
Brief analysis of/etc/default/useradd
Default configuration when adding a user
Inactive=-1 #表示用户创建时默认is not disabled , 0-disabled by default
expire= # expiry time of account
Shell=/bin/shell #用户默认shell, if/sbin/nologin, the new user will not be able to log on by default
Skel=/etc/skel # Newly added user's default profile saved in the original location
create_mail_spool=yes# whether to create a file to save user mail when adding a user
Logon Information configuration file
/ETC/MOTD the information that is displayed after the user logs in, can be used for Insider Notification information [today's message], as long as you log in, you can receive
/etc/issue the information displayed before the user logs in, but it is not recommended to use the original content, which can be used to display Public Information
Example: Manually adding a user
1. Edit the/etc/passwd file to add
Xiaofang::502:502:test User:/home/xiaofang:/bin/bash
2. Create a host directory for Xiaofang: Mkdir/home/xiaofang
3. Change the owner of the directory: Chown Tom/home/xiaofang
4. Edit/etc/shadow, add
Xiaofang::16023:0:99999:7:::
4.cp-rf/ect/skel/.*/home/xiaofang
#新用户信息文件:/etc/skel, which holds some of the new user's configuration files, as long as they are all copied to/home/xiaofang below, the user and useradd to the same user
5.PASSWD xiaofang# Generate Xiaofang Password
At this time
Ok!
Attach-Generate encrypted ciphertext
echo "123456" | Md5sum
Linux User Profiles (second edition)