User and Group Management commands
Useradd: Used to create a new user
Format: useradd [options] User name
-D Specify the user's home directory
-D Show default values
-e account expiration date, format: Yyyy-mm-dd.
-G Specify an initial user group (must already exist)
-g specifies one or more extended user groups
-N does not create a user group with the same name as the user
-s Specifies the default shell
-U specify UID for user
Instance:
[Email protected] ~]# useradd-d/home/linuxs-u 8888-s/sbin/nologin Linuxs
To view basic information about a user:
[[email protected] ~]# ID Linuxs
uid=8888 (Linuxs) gid=8888 (LINUXS) group =8888 (LINUXS)
passwd: Used to modify the user's password
Format: passwd [options] User name
-l lock User against login
-u unlock to allow users to log on to
--stdin allows user passwords to be modified from standard input, such as (echo "123.com" | passwd--stdin Username)
-D make Account no password
-E force user to change password at next logon
-S Displays the user's password status
Instance:
Userdel: Used to delete all user tables
Format: Userdel [options] User name
-F Force removal of users, home directories and their associated files
-R Delete users, home directories and their associated files at the same time
Instance:
[Email protected] ~]# Userdel-r Linuxs
[[email protected] ~]# ID Linuxs
Id:linuxs: No such user
Usermod: Used to modify a user's properties
Format: usermod [options] User name
-C fill in the Account note information
-d-m-M with-D allows you to reassign the user's home directory and automatically transfer the old data to the new home directory
-e account expiry time, format "YYYY-MM-DD"
-G Change the owning user group
-G Change Extended user group
-L lock users against their login system
-U unlocks the user and allows it to log on to the system
-S Change the default terminal
-U modify UID of user
Instance:
[Email protected] ~]# usermod-m-d/home/linuxx linuxs #指定新家目录
[Email protected] ~]# ls/home/
Linuxx
[Email protected] ~]# usermod-u 6666 Linuxs
[[email protected] ~]# ID Linuxs
uid=6666 (Linuxs) gid=8888 (LINUXS) group =8888 (LINUXS)
Groupadd: for creating groups
Format: groupadd [options] Group name
Instance:
[Email protected] ~]# Groupadd Superbsd
Groupdel: Used to delete a group
Format: Groupdel [options] Group name
Instance:
[Email protected]~] #groupdel Superbsd
linux-Fifth Lesson Note-[user and user group actions]