2.27linux and Windows inter-pass files
3.1 User profile and password configuration files
3.2 User Group Management
3.3 User Management
Linux and Windows inter-pass files
Show Dates Date
[Email protected]_1 ~]# Date
November 21, 2017 Tuesday 08:38:25 CST
Display System language
[Email protected]_1 ~]# Echo $LANG
Zh_cn. UTF-8
[Email protected]_1 ~]# Stat 1.txt.bak
File: "1.txt.bak"
Size: 103 Block: 8 IO block: 4096 normal file
Device: 803h/2051d inode:67246931 hard Link: 2
Permissions: (0644/-rw-r--r--) Uid: (0/root) Gid: (0/root)
Last visited: 2017-11-21 08:13:27.682128609 +0800
Last modified: 2017-11-21 08:13:27.682128609 +0800
Last modified: 2017-11-21 08:17:32.976796900 +0800
Creation Time:-
Temporarily set to English:
[Email protected]_1 ~]# lang=en
[Email protected]_1 ~]# Stat 1.txt.bak
File: ' 1.txt.bak '
size:103 blocks:8 IO block:4096 Regular file
device:803h/2051d inode:67246931 Links:2
Access: (0644/-rw-r--r--) Uid: (0/root) Gid: (0/root)
Access:2017-11-21 08:13:27.682128609 +0800
Modify:2017-11-21 08:13:27.682128609 +0800
Change:2017-11-21 08:17:32.976796900 +0800
Birth:-
Linux and Windows inter-pass files:
Premises using Xshell or Securect
Yum Install-y Lrzsz
SZ file Linux upload to Windows/mac
RZ file Windows/mac uploaded to Linux under current directory
User profile and password configuration files
User's password core profile:
cat/etc/passwd
Xiaobo:x:1000:1000::/home/xiaobo:/bin/bash
Xiaobo User Name
X is the password (but hidden, and not put here)
The first 1000 is the UID
The second 1000 is a GID.
/home/xiaobo is home directory
/bin/bash User Login Shell
Files dedicated to user passwords (colon divided into 9 segments)
Cat/etc/shaow
xiaobo:!! : 17486:0:99999:7:::
The first paragraph is the user name
The second paragraph is the password (encryption)
Make two commands in a row with a semicolon to divide:
Display the first and last lines at the same time
[Email protected]_1 ~]# Head-n1/etc/shadow; Tail-n1/etc/shadow
Root:$6$4.plhnd4$o6rzo3hbhuifsgoewt8sjsay5edw7qf9pviflasx3x/ev8ps1m17jb174hjtzimezxzit9jgqrdqhejthm/fa. : 17485:0:99999:7:::
User1:$6$vxwmfyhk$3k5jv3.tf/16mbqkjbdlj6njfpuymxu6eriwfoyyzrcres0ziwxa138/fbgo4pvad1xp4b2gorkdmw/bcx5lm0 : 17491:0:99999:7:::
The date the password was last changed (the date is calculated as the number of days starting January 1, 1970)
View Manpage Shadow
Mans Shadow
Know
The meaning of each field is:
· Sp_namp-pointer to a null-terminated user name
· SP_PWDP-pointer to a null-terminated password
· SP_LSTCHG-
The date the password was last changed (the date is calculated as the number of days starting January 1, 1970)
· Sp_min-days before which password may is not changed
· Sp_max-days after which password must be changed
· Sp_warn-days before password is to expire, user is warned of
Pending password expiration
· Sp_inact-days after password expires the account is considered
Inactive and disabled
· Sp_expire-days since Jan 1, 1970 when account would be disabled
· Sp_flag-reserved for future use
User Group Management
Group Configuration Password:
[Email protected]_1 ~]# Ls/etc/gshadow
Gshadow gshadow-
[Email protected]_1 ~]# Ls/etc/shadow
Shadow shadow-
[Email protected]_1 ~]# ls/etc/passwd
passwd passwd-
To store user groups:
[Email protected]_1 ~]# Ls/etc/group
Group group-
The trailing minus "-" indicates that the system automatically backs up files;
Add Group: Groupadd GRP1
Tail-n1/etc/group
[Email protected]_1 ~]# Groupadd GRP1
[Email protected]_1 ~]# Tail-n1/etc/group
GRP1:X:1003:
Add a group and set the group ID (GID)
[Email protected]_1 ~]# groupadd-g 1005 Grp2
[Email protected]_1 ~]# Tail-n3/etc/group
SLOCATE:X:21:
GRP1:X:1003:
GRP2:X:1005:
Delete a group
[Email protected]_1 ~]# Groupdel GRP2
You cannot delete a group if there are members in it:
[Email protected]_1 ~]# Groupdel user1
Groupdel: Unable to remove the primary group for user "User1"
To remove a user before deleting a group
User Management
Create user
[Email protected]_1 ~]# useradd user2
[Email protected]_1 ~]# tail-n2/etc/passwd
User1:x:1002:1002::/home/user1:/bin/bash
User2:x:1003:1004::/home/user2:/bin/bash
UID starting from 1000
The user's UID and user group can be specified at the time of creation, and the user name is User3
[Email protected]_1 ~]# useradd-u 1005-g grp1 User3
[Email protected]_1 ~]# tail-n1/etc/passwd
User3:x:1005:1003::/home/user3:/bin/bash
[Email protected]_1 ~]# Tail-n1/etc/group
GRP1:X:1003:
Create a uid=1007 for the specified user, belong to the GRP1 group, home directory/home/xiaobo11, specify the user's shell-s/sbin/nologin
[Email protected]_1 ~]# useradd-u 1007-g grp1-d/home/xiaobo11-s/sbin/nologin user5
Do not create a home directory when creating a user
[Email protected]_1 ~]# useradd-m User6
[Email protected]_1 ~]# tail-n1/etc/passwd
User6:x:1008:1008::/home/user6:/bin/bash
[Email protected]_1 ~]# ls/home/
user1/user3/xiaobo11/
By default, when the user is added, the UID will automatically increment when the UID is not set, and the GID is not self-increasing.
AddUser and Useradd commands are the same.
To delete a user command:
Userdel User3
But does not automatically delete the home directory;
Delete the user at the same time delete home directory:
Userdel-r User3
Usermod
Set User uid:
Usermod-u 111 username
Set up user gid
Usermod-g GID username
Set up user home directory
Usermod-d/home/xiaobo11
Set up a user's expansion group
Usermod-g GRP1 Xiaobo
[[email protected]_1 ~]# ID Xiaobo
uid=1009 (Xiaobo) gid=1009 (Xiaobo) group =1009 (Xiaobo)
Add a GRP1 group for Xiaobo users
[Email protected]_1 ~]# usermod-g GRP1 Xiaobo
[[email protected]_1 ~]# ID Xiaobo
uid=1009 (Xiaobo) gid=1009 (Xiaobo) group =1009 (Xiaobo), 1003 (GRP1)
To continue adding extension groups for Xiaobo users, GRP1 will be replaced
[Email protected]_1 ~]# usermod-g Grp2 Xiaobo
[[email protected]_1 ~]# ID Xiaobo
uid=1009 (Xiaobo) gid=1009 (Xiaobo) group =1009 (Xiaobo), 1010 (GRP2)
Change Password
passwd User Name
[Email protected]_1 ~]# passwd Xiaobo
Password is encrypted
[Email protected]_1 ~]# Tail-n1/etc/shadow
Xiaobo:$6$wxnvexw. $MVNPP 6gvutmmjdzfe.ivecna70lqp2nqdskhw1guw3u3uvctb.cwivkqjx5pyadd8n/fgcj0lbibvpwtppt2a0 : 17491:0:99999:7:::
If the password is *, the user is locked out of the login
Bin:*:17110:0:99999:7:::
If the user password is empty, it is two!! Number, the user cannot log on
user4:!! : 17491:0:99999:7:::
Lock user Password
[Email protected]_1 ~]# passwd-l Xiaobo
Locks the password of the user Xiaobo.
PASSWD: Successful operation
[Email protected]_1 ~]# Tail-n1/etc/shadow
xiaobo:!! $6$wxnvexw. $MVNPP 6gvutmmjdzfe.ivecna70lqp2nqdskhw1guw3u3uvctb.cwivkqjx5pyadd8n/fgcj0lbibvpwtppt2a0 : 17491:0:99999:7:::
Unlock user Password
[Email protected]_1 ~]# passwd-u Xiaobo
Unlocks the user Xiaobo password.
PASSWD: Successful operation
[Email protected]_1 ~]# Tail-n1/etc/shadow
Xiaobo:$6$wxnvexw. $MVNPP 6gvutmmjdzfe.ivecna70lqp2nqdskhw1guw3u3uvctb.cwivkqjx5pyadd8n/fgcj0lbibvpwtppt2a0 : 17491:0:99999:7:::
You can also lock the user's password with usermod
[Email protected]_1 ~]# usermod-l Xiaobo
[Email protected]_1 ~]# Tail-n1/etc/shadow
Xiaobo:!$6$wxnvexw. $MVNPP 6gvutmmjdzfe.ivecna70lqp2nqdskhw1guw3u3uvctb.cwivkqjx5pyadd8n/fgcj0lbibvpwtppt2a0 : 17491:0:99999:7:::
Unlock user Password
[Email protected]_1 ~]# usermod-u Xiaobo
[Email protected]_1 ~]# Tail-n1/etc/shadow
Xiaobo:$6$wxnvexw. $MVNPP 6gvutmmjdzfe.ivecna70lqp2nqdskhw1guw3u3uvctb.cwivkqjx5pyadd8n/fgcj0lbibvpwtppt2a0 : 17491:0:99999:7:::
You can also change the user password in this way:
[Email protected]_1 ~]# passwd--stdin Xiaobo
Change the password for the user Xiaobo.
Xiaobo
PASSWD: All the authentication tokens have been successfully updated.
Change Password in shell script
[Email protected]_1 ~]# echo "123456" |passwd--stdin Xiaobo
Change the password for the user Xiaobo.
PASSWD: All the authentication tokens have been successfully updated.
where | is the pipe character, the front echo "12345" to the back of the passwd
Echo-e "123\nsss"
\ n line break
[Email protected]_1 ~]# echo-e "123\nsss"
123
Sss
You can also change the password in this way
[Email protected]_1 ~]# echo-e "12345\n12345" |passwd Xiaobo
Change the password for the user Xiaobo.
New Password: invalid password: password less than 8 characters
Re-enter the new password: passwd: All authentication tokens have been successfully updated.
Linux and Windows Interop files/user profiles and password profiles/user group management/user Management