Linux account and user group

  
        

1. Users and groups
When logging in to Linux, you need to enter a user account. Linux only recognizes the user ID, user ID User ID, referred to as the UID user belongs to the user group, Group ID, referred to as GID.

2. User account
User account is related to two files under Linux: /etc/passwd And /etc/shadow. /etc/passwd to save user account information. /etc/shadow is dedicated to managing password-related data. /etc/passwd file

$ head -4 /etc/passwdroot:x:0:0:root:/root:/bin/bashbin:x:1:1:bin:/bin:/sbin/nologindaemon:x :2:2:daemon:/sbin:/sbin/nologinadm:x:3:4:adm:/var/adm:/sbin/nologin Each line represents an account, and some accounts are required for system operation, referred to as system Accounts, such as bin, daemon, adm, nobody, etc. Use : to separate, a total of 7 fields: 1: Account Name 2: Password Save the password early, the password data is now saved to /etc/shadow, so now x is replaced. 3: UID 0: System administrator, 1-499: System account, 500-65535: General user account. 4: GID Group ID 5: User Information Description Column 6: Main Folder After the user logs in, it will go to the user's home directory. The default user home directory is /home/yourID name 7: The shell obtained by the shell user after login. /etc/shadownfile
$ head -4 /etc/shadowroot:$1$l0aFE9hs$d1/FIMqIl3foYUl3ETyk10:16353:0:99999:7:::bin:*:13361:0:99999:7:::daemon :*:13361:0:99999:7:::adm:*:13361:0:99999:7:::View permissions, generally set to root read-only 
ll /etc/shadow-r---- ---- 1 root root 1085 Nov 21 03:40 /etc/shadow according to: Separate, a total of 9 fields 1: Account Name 2: Password encrypted password field. 3: The date the password was last changed is the number of days accumulated in 1970-01-01. 4: The number of days when the password cannot be changed is 0. No limit 5: The number of days that the password needs to be re-modified is 273 years after the calculation of 99999, 6: The number of warning days before the password is changed. 7: The account grace period can be logged in after the password expires. After forced change password 8: Account expiration date account will no longer be used 9: Reserved field 

3. User group
User group data is saved in /etc/group file

$ head -4 grouproot:x: 0:rootbin:x:1:root,bin,daemondaemon:x:2:root,bin,daemonsys:x:3:root,bin,adm line represents a user group, the file is separated by: 4 columns: 1: user Group Name 2: The user group password usually does not need to be set. The password file is /etc/gshadow 3: GID 4: User supported by the user group. Initial user group initial group: The GID in /etc/passwd is the user initial user group. The effective user group. A user can have multiple groups. The current group is a valid user group. 
$ groupsroot bin daemon Use the groups command to view The user's group, the first one that appears is a valid user group. Use newgrp groupname to switch groups. /etc/gshadow Group password file 
head -4 /etc/gshadow root:::rootbin:::root,bin,daemondaemon:::root,bin,daemonsys:::root,bin,adm use: separate, 4 column 1: group name 2: password 3: user group administrator account 4: user account of the user group.
Copyright © Windows knowledge All Rights Reserved