I. User Profile 1 user information file/etc/passwd
vim/etc/passwd
First field: User name
Second field: Password flag (x indicates a password)
Third field: User ID (UID)
0: Super User
1-499: System User (pseudo user)
500-65536: Normal User
Fourth field: User initial group ID (GID)
Initial group: Refers to the user immediately login to have this group of relevant permissions, each user initial group only one, generally with the user name as the user's initial group name.
Additional groups: Users can join multiple additional groups and have permissions for those groups
Fifth field: User description
Sixth field: Home directory
Super User home directory:/root/
Normal User home directory:/home/user name/
Seventh field: Shall after logging in
Shell is the command interpreter for Linux
/bin/bash Allow log in
/sbin/nologin not allowed to log in
2 Shadow File/etc/shadow
Vim/etc/shadow
First field: User name
Second field: Encrypt password
SHA512 Hashing Encryption algorithm
If the password bit is "!!" or "*", it means no password and cannot log in
Third field: Password Last modified date
Use 1970.1.1 as standard time, every day time stamp plus 1
Time Stamp Conversion |
Date, time stamp |
Echo $ (($ (Date--date= "2014/01/06" +%s)/86400 + 1)) |
Time Stamp, date |
Date-d "1970-01-01 16066 Days" |
Fourth field: two times password modification interval
Fifth field: Password expiration
Sixth field: Number of days before expiration of the password expiration date
Seventh field: The number of days after which the password expires
0: Expire immediately after the password expires
-1: The representative password will never expire
Eighth field: Account Expiration time (timestamp indication)
Nineth field: Reserved
3 Set of information files/etc/group
Vim/etc/group
First field: Group name
Second field: Group password flag
Third field: Group ID (GID)
Fourth field: Additional users in the group
4 set of password files/etc/gshadow
Vim/etc/gshadow
First field: Group name
Second field: group password
Third field: Group Administrator user name
Fourth field: Additional users in the group
II. user Management Related documents 1 user's home directory
Normal User:/home/user name/
Super User:/root/
2 User's mailbox file
/var/spool/mail/User Name
3 User Templates Directory
/etc/skel/
Used to save files that are automatically generated when a new user is created, such as creating a new file in the directory notice.msg the notice.msg file is created automatically when you create the user
4 Adding a user default value file
/etc/default/useradd
group=100 |
User Default Group |
Home=/home |
User home Directory |
Inactive=-1 |
Password Expiration Grace days |
Expire= |
Password Expiration Time |
Shell=/bin/bash |
Default shell |
Skel=/etc/skel |
Template Catalog |
Create_mail_spool=yes |
Whether to create a mailbox |
/etc/login.defs
Pass_max_days 99999 |
Password expiration |
Pass_min_days 0 |
Password modification interval |
Pass_min_len 5 |
Password minimum 5 bit |
Pass_warn_age 7 |
Password Expiry warning time |
Uid_min 500 Uid_max 6000 |
Minimum maximum UID Range |
Encrypt_method SHA512 |
Encryption mode |
III. User Management Commands 1 adding users
Useradd [-udcggs] User name
-U UID
-D Home Directory
-C User Description
-G Group name (initial group)
-G Group name (additional group)
-s command interpreter shell (default/bin/bash)
Example: Useradd-u 666-g root,bin-c "test user"-d/home/zhw-s/bin/bash ZHW
2 Modifying user passwords
passwd [Options] [user name]
Cases:
Passwd-s user1 Query the password status of User1 password (root user only)
Passwd-l User1 temporarily lock user (root user only)
Passwd-u user1 unlock user (root only)
echo "123" | passwd--stdin Use a string as the user's password
3 Modifying user Information
Usermod [-ucggdlu] [user name]
-U UID
-D Home Directory
-C User Description
-G Group name (initial group)
-G Group name (additional group)
-s command interpreter shell (default/bin/bash)
-L Lock User
-U Unlock User
4 Modifying User Password status
chage [-ldmmwie] User name
-l list user detailed password status
-D Change the password last changed date ( when-D 0 requires the user to change the password as soon as it is logged in )
-M two times password change interval
-M Password expiration date
-W warning days before password expires
-I Grace days after password expires (I)
-E Account Expiry time
5 Deleting a user
Userdel [-r] User name
-R Delete User's home directory while deleting user
6 Viewing user IDs
ID User name to view the UID, GID, and owning group of the user
7 See which user is currently
WhoAmI
8 Viewing User Environment variables
Env
9 User Switching
Su-User name switches the user's environment variables together
su-root-c "Useradd user2" add a user with root privileges user2
10 viewing logged-in user information
W.H.O.
Display: Log in username login Terminal login time
TTY indicates local terminal
PTS indicates a remote terminal
11 View Log in User details
W
Display: Current time continuous run time (uptime) Number of users load Balancing index
Login Username-Login terminal-Login IP address-Login time-idle time-Cumulative CPU time-current CPU time-work command
Iv. User Group Management Command 1 adding user groups
Groupadd [-g] Group name
-G Specify Group ID
2 Modifying user groups
Groupmod [-GN] group name
-G Modify Group ID
-N Modify Group name
Example: Groupmod-n G2 G1 Change the name of the group G1 to G2
3 Deleting a group
Groupdel Group Name
Note: You cannot delete the user's initial group, delete the user and then delete the group, but the user's additional group can be deleted
4 Adding a user to a group or removing it from a group
gpasswd-a User name Group name join a user to a group
gpasswd-d User Name Group name removes the user from the group
Linux Learning-User and user group management