User: uid is stored in /etc/passwd
User classification:
- admin uid--0
- general user
--system user uid 1-499
--General user uid 500-60000
Group: gid is stored in /etc/group
group classification
- basic group
- Private group: When no group is assigned when creating a user, the system automatically creates a private group for it
- Additional group
/etc/passwd file: save system user information
root:x:0:0:root:/root:/bin/bash
account : root -- username
password : x -- password placeholder
uid :0
Guide : 0
commit : root --comment
root : root -- home directory
shell : /bin/bash -- default assigned shell
/etc/shadow file
eco: $ 1 $ 0W0cNPya $ 9QSgsLssXdn7OE0BNiXjN1: 17651: 0: 99999: 7 :::
account : eko --login
eencryp password: $1$0W0cNPya$9QSgsLssXdn7OE0BNiXjN1 -- encrypted password
last password change: 17651--last modification time
User Management
- Add user:
useradd
options:
-r system user
-u manually specify uid
-g manually specify gid (basic group, must exist)
-G additional group (can be multiple, use, separated groups must exist in advance)
-c comment information
-d specify home directory
root @ ubuntu: / home / eco # useradd tom
- Assign passwords to users
root @ ubuntu: / home / eko # passwd tom Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully
- View the currently logged in user id gid
# id uid=0(root) gid=0(root) groups=0(root)
- View user information account information
finger UserName
- delete users
userdel UserName
- modify user
usermod -u UID -g GID
group management
- Add group
groupadd -g GID -r system group
- Modify group
groupmod -g GID -n group name
- delete group
groupdel group name
- Set group password
gpasswd
- Log in to the new group with the current user
newgrp group name Exit the group: exit
authority management
- Change file owner (only administrators have permission)
chown User file1,file2...
option
-R recursively modify the directory and the owner of the file in the directory
- Change file group (administrator)
chgrp GroupName file1,file2...