User profile and password profile user profiles
[Email protected] ~]# Cat/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. Avahi-autoipd:x:170:170:avahi IPv4LL Stack:/ VAR/LIB/AVAHI-AUTOIPD:/SBIN/NOLOGINPOSTFIX:X:89:89::/VAR/SPOOL/POSTFIX:/SBIN/NOLOGINSSHD:X:74:74: Privilege-separated ssh:/var/empty/sshd:/sbin/nologinchy002:x:1000:1000::/home/chy002:/bin/bashuser:x:1001:1001 ::/home/user:/bin/bash#passwd file divided into 7 fields by ":" # first column: Username # second column: User password, based on security factors, all put in the/etc/shadow # third column: User ID number UID. Root is reserved for the 0,1-999 system. 1000 later for normal user # Fourth column: Group identification number gid# Fifth column: Comment Description # Sixth column: User home directory. /home/User name # Seventh column: the user's shell. Users can log in must have an interactive terminal, and/sbin/nologin not allowed to log in
Password file
[Email protected] ~]# cat/etc/shadowroot:$6$jy. Mwzub$pvmbm2suh583kebbn4xnrspahg0yytpmz90c1jvqwq5hnkcnvpwsn31sxvz3mm2ftujwwiezpwwulzy6xwedl0:17458:0:99999:7:: : Bin:*:16231:0:99999:7:::d aemon:*:16231:0:99999:7:::adm:*:16231:0:99999:7:::lp:*:16231:0:99999:7:::sync:* : 16231:0:99999:7::: ... postfix:!! : 17455::::::sshd:!! : 17455::::::chy002:!! : 17463:0:99999:7:::user:!! : 17463:0:99999:7::: #与/etc/passwd corresponding, specifically used to control the user password, by: Split into nine # first column: User name # second column: User password. After it has been encrypted. #第三列: The date the password was last changed. The number of days from January 1, 1970. #第四列: How many geniuses you can change your password. #第五列: The password expires after a few days. #第六列: The warning period before the password expires. #第七列: Password expiration period. #第八列: Account life cycle # Nineth column: reserved, meaningless.
User Group Management
[Email protected] ~]# cat/etc/group #组管理目录root: x:0:bin:x:1:daemon:x:2: ... #其中带-Files are automatically backed up by the system [email Protected] ~]# Ls/etc/shadowshadow shadow-[[email protected] ~]# Ls/etc/gshadowgshadow gshadow-[[email Protected] ~]# ls/etc/passwdpasswd passwd-[[email protected] ~]# ls/etc/groupgroup group-#添加一个用户组 [[Email Protected] ~]# groupadd gpp1[[email protected] ~]# tail-n1/etc/groupgpp1:x:1002: #添加一个用户组 and specify the group number [[email protected] ~]# GR Oupadd-g 1003 gpp2[[email protected] ~]# tail-n1/etc/groupgpp2:x:1003:[[email protected] ~]# Tail-n3/etc/groupscreen: x:84:gpp1:x:1002:gpp2:x:1003: #可以删除一个空组, but cannot delete a package containing the user's group [[email protected] ~]# Groupdel gpp2[[email protected] ~]# Groupdel Chy002groupdel: Cannot remove primary group for user "chy002"
User Management
[[email protected] ~]# useradd user1[[email protected] ~]# tail-n3/etc/passwdchy002:x:1000:1000::/home/ chy002:/bin/bashuser:x:1001:1001::/home/user:/bin/bashuser1:x:1002:1002::/home/user1:/bin/bash[[email Protected] ~]# useradd-u 1004-g user1 user2[[email protected] ~]# Tail-n3/etc/passwduser:x:1001:1001::/home/user :/bin/bashuser1:x:1002:1002::/home/user1:/bin/bashuser2:x:1004:1002::/home/user2:/bin/bash[[email Protected] ~]# tail-n3/etc/groupuser:x:1001:screen:x:84:user1:x:1002:[[email protected] ~]# useradd-u 1005-g user1-d/tmp/user3-s/sbin/nologin user3 #-u Specify uid-d Specify home directory-s Specifies that the shell is creating a mailbox file: The file already exists [[email protected] ~]# tail -n3/etc/passwduser1:x:1002:1002::/home/user1:/bin/bashuser2:x:1004:1002::/home/user2:/bin/bashuser3:x : 1005:1002::/tmp/user3:/sbin/nologin[[email protected] ~]# ls/tmp/user3/[[email protected] ~]# ls/tmp/ 123.txt 1.txt 2.txt 321.txt 3.txt chy chy2 chy2.txt Chyur user3[[email protected] ~]# useradd-m user4 #-m do not create home directory [[email protected] ~]# Tail-n3/etc/passwduser2:x:1004:1002::/home/user2:/bin/bash User3:x:1005:1002::/tmp/user3:/sbin/nologinuser4:x:1006:1006::/home/user4:/bin/bash
Delete User
[Email protected] ~]# useradd user10[[email protected] ~]# tail-n2/etc/passwduser4:x:1006:1006::/home/user4:/bin/ Bashuser10:x:1007:1007::/home/user10:/bin/bash[[email protected] ~]# ls/home/chy002 user user1 user10 user1009 user1999 user2 user3 user8[[email protected] ~]# Userdel user10[[email protected] ~]# Tail-n2/etc/passwduser3:x:1005:1002::/tmp/user3:/sbin/nologinuser4:x:1006:1006::/home/user4:/bin/bash[[email Protected] ~]# ls/home/chy002 user user1 user10 user1009 user1999 user2 User3 user8# can find that Userdel just deleted the user, and not delete the user home directory # can use the -r option, while removing the user and home directory
Linux3.1 user profile and user group management