First, user and group of related files
/etc/passwd : user and its attribute information file format: root:x:0:0:root:/root:/bin/bash Username: Password: uid:gid: Description Information: Home directory: Default shell #============================================================ ========================== /etc/shadow : User password store information file format: root:xxxxx:17485:0:99999:7::: user name: encrypted password: Password modification time: Minimum validity: Maximum period: Advance reminder number of days to change password: expired n days after the login: account validity #====================================================================== ================ /etc/group : Group and its attribute information file format: root:x:0: Group name: Group password: Group ID: team member #================================================== ==================================== /etc/gshadow : group Password and its attribute information file format: root:x:x: Group name: password: Group Administrator: Team member #======================================================================================
Second, the user management of the relevant orders
1. User add: Useradd
Usage:useradd [options] login -u uid: Specify UID    -G GID: Specify a basic group, you can use the group name to specify -d HOME_DIR: specify the home (nonexistent) directory -s SHELL: specify default shell -g group1[,group2,...]: To specify additional groups for the user, the group must exist -r : Create System User (default does not create home directory) -m : Force home Directory, with-R use -N : do not create basic groups with the same name, use the Users group to do basic groups -M : do not create home directories -o : with-u use, do not check UID uniqueness -c : Add description information newusers file : batch create user, need to be prepared with passwd format file chpasswd : Bulk Modify user password, file format: User name: Password Example: cat password.txt | chpasswd /etc/default/useradd : Create a user's default file useradd -d: Show default values useradd -D -s shell : Modifying the default SHELL    USERADD -D -B BASE_DIR &NBSP: Modify default home directory Useradd -d -g group: Modify the default group/etc/login.defs : detailed create user profile/etc/skel/ : User home directory of the. BASHRC ... Documents, etc. #======================================================================================
2. Modify User password: passwd
Usage: passwd [options] UserName passwd: Modify your own password options:-L: Lock specified user-u: Unlock specified user-e: Force user to change password at next logon--stdin: Receive from standard input User Password Example: echo "PASSWORD" | passwd--stdin USERNAME #======================================================================================
3. Modify user information: Usermod
Usage: usermod [options] login-g GID: Modify user base Group-G GID,GID1: Modify user Additional group-a: With-G use, add additional group-L New_name: Modify user logon Name- L: Lock the user, will be added in the/etc/shadow password bar! -U: Unlock user-E yyyy-mm-dd: Specify user account expiration date-D DIR: Modify home Directory-M: with-D, modify and move data to the new home directory #================================== ====================================================
4. Delete User: Userdel
Usage: Userdel [options] login-r: Delete home directory-F: Force Delete #==================================================================== ==================
5. View user-related ID information
ID: Show User ID number usage: id [OPTION] ... [User]-U: Display uid-g: Display gid-g: Displays the id-n of the group to which the user belongs: Display name, with-G use #=============================================== =======================================
Iii. related commands for group management
1. Create and delete groups: Groupadd, Grupdel
Create group: Usage: groupadd [options] Group option:-G GID: Specify GID-R: Create System Group Delete Group: Groupdel Group #============================== ========================================================
2. Modify Group Properties: Groupmod
Usage: groupmod [options] Group options:-N group_name: Modify group name-G GID: Modify gid#================================================= =====================================
3. Change group Password: gpassed
Usage: gpassed [options] Group options:-A User: Add users to Group-D User: Remove user from group-a user1,user2 ...: Set group Administrator #=========== ===========================================================================
4. Change Group members: Groupmems
Usage: groupmems [options] [action] option:-G,--group groupname: Change to specified group-a,--add Username: Add user to Group-d,--Delete Usern Ame: Remove users from Group-P,--purge: Clears all members of the group-l,--list: Displays the group member list #================================================== ====================================
This article is from the "Bigboss" blog, make sure to keep this source http://bigboss.blog.51cto.com/12113895/1982128
Users and Groups for Linux