Linux account management

  
1. Add user Add user to use useradd command useradd [-c comment] [-d home_dir] [-e expire_date] [-f inactive_time] [-g initial_group] [-G group[,... ]] [-m [-k skeleton_dir] |  -M] [-n] [-o] [-p passwd] [-r] [-l] [-s shell] [-u uid] login -c Description -d specifies the home folder instead of the default -e account expiration date -f shadow seventh field option, password expired, -1 is never valid -g initial user group -G this account can also join the group name -m user home directory if it does not exist, if Set -k, the file below the skeleton_dir will be copied to the main directory. -M does not create user home directory, system account default value -s shell -u user uid View useradd default value # useradd -D GROUP=100 HOME=/home INACTIVE=-1 EXPIRE= SHELL=/bin/bash SKEL=/etc /skel These data provide the SKEL user home folder reference directory in the /etc/default/useradd file. When creating a user, copy it from the directory to the user's home directory, including .bashrc, .bash_profile, etc. User UID/GID, and some encryption parameters, they reference value /etc/login.defs #QMAIL_DIR Maildir MAIL_DIR /var /spool /mail #MAIL_FILE .mail # password aging controls:. # # PASS_MAX_DAYS Maximum number of days a password may be used # PASS_MIN_DAYS Minimum number of days allowed between password changes. # PASS_MIN_LEN Minimum acceptable password length. # PASS_WARN_AGE Number of days warning given before a password expires. # PASS_MAX_DAYS 99999 PASS_MIN_DAYS 0 PASS_MIN_LEN 5 PASS_WARN_AGE 7 # # Min /max values ​​for automatic uid selection in useradd # UID_MIN 500 UID_MAX 60000 # # Min /max values ​​for automatic gid selection in groupadd # GID_MIN 500 GID_MAX 60000 # # If useradd should create home directories for users by default # On RH systems, we do. This option is ORed with the -m flag on # useradd command line. # CREATE_HOME yes 2. Modify the user Change the password passwd passwd [--stdin] username passwd username stdin : You can change the password through the pipe echo "adcd" |  Passwd --stdin user1 passwd does not add an account to modify the current user password -l : lock lock password, add /in the second column of /etc/shadow, invalidate the password. -u; unlock -S; password parameters listed may also be used to view the user information chage # chage -l user1 Minimum: 0 Maximum: 99999 Warning: 7 Inactive: -1 Last Change: Dec 27, 2014 Password Expires: Never Password Inactive : Never Account Expires: When the userset setting error occurs, you can use usermod to modify the information # usermod -h usage: usermod [-u uid [-o]] [-g group] [[-a] -G group,...] [-d home [-m]] [-s shell] [-c comment] [-l new_name] [-f inactive] [-e expire ] [-p passwd] [-L| -U] name 3. Delete user userdel delete user # userdel -r help -r Delete along with the main folder. 4. Review the user information finger: the user can check the information, do not take back the user can query the currently logged on user name # finger work Login: work Name: (null) Directory: /home /work Shell: /bin /bash On since Sat Dec 27 17:20 (CST) on pts /1 from yongang.m 14 minutes 15 seconds idle No mail No Plan chfn:.. this information Review: change finger id: uid view information [root @ www home] # id uid = 0 ( Root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel) [root@www home] # id work uid=500(work) gid=502(work) groups=502(work) 5. Add group groupadd for new user group groupadd [-g gid] [-r] groupname -g : specify group id - r: system user group 6. modify group groupmod modify user group
Copyright © Windows knowledge All Rights Reserved