Linux Learning 7 user management related files R

Source: Internet
Author: User
Tags set time

7.1, User Configuration files7.2, user management related files7.3, user management commands7.4, user Group Management Command Delete user Userdel [[email protected]~]# Userdel [-r] User name//Be sure to add-R to delete home directoriesIn addition to the command modification, you can also directly in the file modification, more direct, not easy to write wrong. The execution of the original command is also to write to the file user's initial group is bound with the user, generally do not recommend modification. -----------------------------------7.1.1User Information file/etc/passwd7.1.2Shadow file/etc/Shadow7.1.3Group information file/etc/group and group password file/etc/Gshadow7.1.2Shadow file/etc/Shadow1, Shadow file/etc/shadow? 1th field: User name? 2nd field: Encrypted password? The encryption algorithm is upgraded to the SHA512 hash encryption algorithm? If the password bit is "!!” or "*"Does the representative have no password and cannot log in?" 3rd field: Password Last modified date? Use January 1, 1970 as standard Time, every day timestamp plus 1? The 4th field: two times the password is modified (compared to the 3rd field)? 5th field: Password expiration (compared to the 3rd field)? 6th field: Number of warning days before password modification expires (compared to the 5th field)? field: Number of days after password expires (compared to the 5th field)?0: Expire immediately after the password expires?-1: The password will never expire. 8th field: Account Expiration time? To use a timestamp? the 9th field: Reserved2, timestamp conversion? Convert timestamps to dates? Date-D"1970-01-01 16066 days"? Convert date to timestamp? Echo $ (($ (Date--date="2014/01/06"+%s)/86400+1))
7.2, user management related files1, the user's home directory for ordinary users:/home/User name/, the owner and the owning group are the users, and the permissions are 700 super users:/root/, the owner and the owning group are root users and the permissions are 550//permission is not 7 Ah, it seems that the teacher said because Root is a rogue, so it can do what it wants2, the user's mailbox?/var/spool/mail/User name/3, User templates directory?/etc/skel/7.3User Management Commands7.3.1user add Command Useradd7.3.2Modify user Password passwd7.3.3Modify user Information usermod Modify user password status Chage7.3.4Remove user userdel user switch command su1, useradd command format [[email protected]~] #useradd [options] User name options:-u uid: Manually specify the UID number of the user-D Home Directory: Manually specify the user's home directory//The default is good-C User Description: Manually specify the user's description//double quotation marks for spaces-G Group Name: Manually specify the user's initial group-G Group Name: Specify the user's additional group//separate multiple groups with commas-S Shell: Manually Specify the user's login shell. Default is/bin/Bash2, add default users? [[Email protected]~]# useradd lamp? [[Email protected]~]# grep"Lamp"/etc/passwd? [[Email protected]~]# grep"Lamp"/etc/shadow? [[Email protected]~]# grep"Lamp"/etc/Group? [[Email protected]~]# grep"Lamp"/etc/Gshadow? [[Email protected]~]# ll-d/home/lamp/? [[Email protected]~]# LL/var/spool/mail/Lamp3, specify options to add users? Groupadd lamp1?useradd-U550-G lamp1-g root-d/home/lamp1 \-C"Test User"-s/bin/Bash LAMP14, user default value file?/etc/default/Useradd? GROUP= -#用户默认组? HOME=/Home #用户家目录? INACTIVE=-1#密码过期宽限天数 (7)? EXPIRE= #密码失效时间 (8)? SHELL=/bin/bash #默认shell? SKEL=/etc/Skel #模板目录? Create_mail_spool=Yes #是否建立邮箱?/etc/login.defs? Pass_max_days99999#密码有效期 (5)? Pass_min_days0#密码修改间隔 (4)? Pass_min_len5#密码最小5位 (PAM)? Pass_warn_age7#密码到期警告 (6)? Uid_min -#最小和最大UID范围? Gid_max60000? Encrypt_method SHA512 #加密模式7.3.2Modify user Password passwd1, passwd command format [[email protected]~] #passwd [options] User name options:-S queries the password status of the user's password. Only the root user is available. -• Temporarily lock the user. Only the root user is available-u unlock the user. Only the root user is available--stdin can be used as the user's password through the data exported by the pipe character. 2, check your password status? [[Email protected]~]# passwd-S lamp PS -- on- . 0 99999 7-1#用户名 Password Set time ( -- on- .) Password modification interval time (0) #密码有效期 (99999) Warning Time (7) password does not expire (-1)3, lock the user and unlock the user? [[Email protected]~]# passwd-l lamp? [[Email protected]~]# passwd-u lamp4, use a string as the user's password? [[Email protected]~]# Echo"123"| passwd--stdin Lamp7.3.3Modify user Information usermod Modify user password status Chage1, modify user information Usermod[[email protected]~] #usermod [options] User name options:-u uid: Modify UID number of user-C User Description: Modify user's description information-G Group Name: Modify the user's additional group-L: Temporary lock User (lock)-U: Unlock user lock (Unlock)? [[Email protected]~]# usermod-c"Test User"lamp #修改用户的说明? [[Email protected]~]# Usermod-G root lamp #把lamp用户加入root组? [[Email protected]~]# Usermod-L lamp #锁定用户? [[Email protected]~]# Usermod-U lamp #解锁用户2, modify user Password status Chage//Direct modification of the shadow file is more intuitive and requires only-D[[Email protected] ~] #chage [options] User name options:-L: List the user's detailed password status-D Date: Change Password last change date (shadow3 field)//if it is 0, then the system believes that the password has never been changed, so that the user login will be the password-m days: two password modification intervals (4 fields)-M days: Password expiration date (5 field)-W days: Number of warning days before password expiration (6 field)-I days: Password after grace days (7 fields)-E Date: Account Expiration Time (8 field)? [[Email protected]~]# chage-d0Lamp #这个命令其实是把密码修改日期归0了 (Shadow 3rd field) #这样用户一登陆就要修改密码
7.3.4Remove user userdel user switch command su1, delete user Userdel [[email protected]~]# Userdel [-r] User name//Be sure to add-rOptions:-r Delete User at the same time delete user home directory manually delete user//Useradd again, see if you can add success, then prove the deletion succeeded? [Email protected] ~]# vi/etc/passwd? [[Email protected]~]# vi/etc/shadow? [[Email protected]~]# vi/etc/Group? [[Email protected]~]# vi/etc/Gshadow? [[Email protected]~]# RM-RF/var/spool/mail/lamp? [[Email protected]~]# rm-rf/home/lamp/2, view users id[[email protected]~]# ID User name3, switch user identity su[[email protected]~]# su [options] User name options:-: Option to use only "-"To switch between the environment variables representing the associated user-C command: Executes only one command at a time without switching user identities? [[Email protected]~]$ su–root #切换成root? [[Email protected]~]$ su-root-c"Useradd User3"#不切换成root, but execute useradd command to add User1 user7.4User Group Management command groupaddgroupmod modify the user group name Groupdel Delete the group without the initial user gpasswd add or remove users from the group-A,-D//directly change the file/etc/group more directly, because the command is easy to remember wrongThe initial group is not recommended to change, the default is added to the additional group

Linux Learning 7 user management related files R

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.