Realize that Linux's rights management actually does not recognize your username and password but recognize your UID and GID plainly, is your user ID and group ID
The code is as follows:
>cat/etc/passwd
Root:x:0:0:root:/root:/bin/bash
Daemon:x:1:1:daemon:/usr/sbin:/bin/sh
The top 0 is the user ID, the group ID is also 0, of course, my current user root
User login, will be based on your username, such as my root to/etc/passwd there is no this user, if there is no jump out, if there is to/etc/shadow to find the corresponding UID password, and finally execute login
The code is as follows:
Root:x: 0:0: Root:/root:/bin/bash
Root #用户名
x #代表口令, now stored in/etc/shadow.
0 #用户的Uid
#其中0是root, 1-100 is automatically created by the distribution, 100-499 is the system requirements can be created, 500 after the general use of
0 #用户的GId
Root #用户信息栏说明
/root #家目录
/bin/bash #支持shell
#/etc/shadow
>cat/etc/shadow
Root:$6$5sjcajas$eh0r0lsapawsmpoz5zoz4isavi7nr./vvmui5gnfylsscvs7ftwz9jk7e8.. Bnajm7jv2qbbn9fck5oigzx0n1:16147:0:99999:7:::
Root #用户名
$ ... 1 #特别长那个是密码
16147 #更改口令的日期
0 #口令可以更改的日期, that is, relative to the last 16147 change date, 0 is to modify at any time
99999 #口令重新变更的天数
7 #口令警告, the password is expired, Windows users should have seen
The 7th one has no value #这个是口令失效日期
A 8th field #帐号失效日期
A 9th field #保留
General Use commands
Useradd-g User Secondary Group
The code is as follows:
>usermod-g Users Xiaowei
>grep Xiaowei/etc/shadow/etc/passwd/etc/group
/etc/shadow:xiaowei:!:16147:0:99999:7:::
/etc/passwd:xiaowei:x:1001:1001::/home/xiaowei:/bin/sh
/etc/group:users:x:100:xiaowei
/ETC/GROUP:XIAOWEI:X:1001:
Groups supported by groups
The code is as follows:
> Groups
Root Xiaowei
NEWGRP Switching Group
The code is as follows:
>newgrp Xiaowei
>id
Uid=0 (Root) gid=1001 (Xiaowei) groups=0 (Root), 1001 (Xiaowei)
Useradd Add Account
Useradd [-U UID] [g Initial group] [G Secondary group] [-MM] [-C description bar] [D-House Directory Absolute Path] [-s shell] user account name
Options and Parameters:
-u : The following is the UID, which is a set of numbers. Specify a specific UID directly to this account;
-g : The group name that follows is the one we mentioned above initial group ~
The group's GID is placed in the In the fourth field of the etc/passwd.
-g : The group name that is followed by this account can also be added to the groups.
This option and parameters will modify the relevant data in/etc/group Oh!
-m : Mandatory! Do not create user home directory! (System account Default value)
-m : Mandatory! To create a user home directory! (General account default value)
-c : This is/ETC/PASSWD's fifth column of the description of the content of the ~ can be arbitrarily we configure the ~
-d : Specify a directory to become home directory, rather than using default values. Be sure to use an absolute path!
-r : Create a System account, the UID of this account will have restrictions (refer to/etc/login.defs)
-s : After a shell, if not specified then the default is/bin/bash ~
E : followed by a date, formatted as "YYYY-MM-DD" This item can be written to the shadow eighth field,
i.e. account expiration Day configuration item??? br/>-f : The Seventh field item, followed by shadow, specifies whether the password will fail. 0 for immediate expiration,
1 is never invalidated (the password expires and is forced to reconfigure on login). )
The code is as follows:
# Add a widuuweb user, UID for 800 group id1001 Force create home directory, described as test home directory/root/test not allowed to log in
> Useradd-u 800-g 1001-m-C test-d/root/test-s/sbin/nologin Widuuweb
> grep widuuweb/etc/passwd
Widuuweb:x:800:1001:test:/root/test:/sbin/nologin
passwd Modify Password
passwd [-L] [-u] [--stdin] [-S] [-N days] [x days] [w days] [-I date] account <==root function
Options and Parameters:
--stdin: It can be used as a password input from the data from the previous pipeline to help the shell script!
-L: Is the meaning of Lock, will/etc/shadow the second column of the front Plus! Invalidate the password;
-U: Relative to-l, it means Unlock!
-S: Lists password-related parameters, that is, most of the information in the shadow file.
-N: Followed by days, shadow 4th field, how long can not be modified password days
-X: After days, the 5th field of shadow, how long must the password be altered
-W: Followed by days, shadow 6th field, warning days before password expiration
-I: Follow "date", Shadow 7th field, password expiration date
>passwd-l Xiaowei #这个时候就锁定无法登录了
>passwd-u Xiaowei #解锁可以登录了
>PASSWD Xiaowei #输入密码更换密码
#同passwd-S has the same functionality as Chage
Options and Parameters:
-L: Lists the detailed password parameters for the account;
-D: Follow the date, modify the Shadow third field (the date the password was last changed), format YYYY-MM-DD
-E: Follow date, modify shadow eighth field (account expiration date), format YYYY-MM-DD
-I: After days, modify shadow seventh field (password expiration date)
-M: Follow the number of days, modify the Shadow fourth field (Minimum password to retain the number of days)
-M: After days, modify the Shadow fifth field (how long the password needs to be changed)
-W: After days, modify the Shadow sixth field (warning date before password expires)
Usermod Modify User Parameters
-C: The description of the following account, that is,/etc/passwd the fifth column of the description, you can add some account description.
-D: Back to the home directory of accounts, that is, modify the/etc/passwd of the sixth column;
-E: followed by the date, the format is Yyyy-mm-dd is the/etc/shadow in the Eighth field data!
-F: followed by the number of days, the seventh field of shadow.
-G: After the initial group, modify the fourth field of/etc/passwd, which is the field of GID!
-G: Follow the secondary group, modify the group that the user can support, modify the/etc/group??? br/>-A: Combined with-G to "add support for secondary groups" instead of "Configuration" Oh!
-L: Take account name back. That is to modify the account name,/etc/passwd the first column!
-S: After the Shell's actual files, such as/bin/bash or/BIN/CSH, and so on.
-U: next to the UID number! That is, the data in the third column of/etc/passwd;
-L: Temporarily freeze the user's password so that he cannot log in. In fact, only change/etc/shadow password bar.
-u: will/etc/shadow password bar! Take it off, thaw it!
The code is as follows:
>usermod-c Nihao Xiaowei
Xiaowei:x:1001:1001:nihao:/home/xiaowei:/bin/sh
>usermod-d/root/xiaowei Xiaowei #xiaowei家目录就是这个位置了
>usermod-s/sbin/nologin Xiaowei
>su Xiaowei
#无法登录了
Cannot execute/sbin/nologin:no such file or directory
Userdel Delete User
The code is as follows:
>userdel widuuweb #删除用户 Userdel-r widuuweb together with home directory delete
Id
I used it in front.
The code is as follows:
>id Xiaowei #显示用户的用户群组信息
uid=1001 (Xiaowei) gid=1001 (Xiaowei) groups=1001 (Xiaowei), (users)
Groupadd Add a group
The code is as follows:
>groupadd-g 102-r Xiaowei #-g Group ID Optional-R group name
>groupadd Widuuweb
> grep widuuweb/etc/group
#widuuweb: x:1003:
Groupmod Modify Group Information
The code is as follows:
Groupmod [G-GID] [-n group_name] group name
>groupmod-g 201-n Widuu Xiaowei
Groupdel Delete Group
The code is as follows:
>groupdel Widuu
GPASSWD Group Management
Options and Parameters:
: If you don't have any arguments, give GroupName a password (/etc/gshadow)
-A: Assign the GroupName master to the following user management (Administrator of the group)
-M: Add some accounts to this group!
-R: removing groupname password
-R: Let GroupName's password bar fail
The code is as follows:
>gpasswd-a Xiaowei Widuu #xiaowei加入widuu群组
>GPASSWD Widuu #设置口令
>GPASSWD Widuu xiaowei1 #讲xiaowei1加入群组