Useradd Create users, usermod Modify user properties, Userdel delete users, groupadd create groups, Groupmod modify group properties, Groupdel delete groups. Create user command: Useradd syntax:
useradd [option] ... login
Common options:
-U uid: Specifies uid;
-G Group: Specifies the base group ID, which needs to exist beforehand;
-G GROUPS: Specifies additional groups, separated by commas between multiple groups;
-D Home_dir: Specify the user's home directory;
-S Shell: Specifies the user's default shell;
-r: Create a System user.
Note: The new user does not have a password by default.
Set User password command: passwd syntax:
PSASWD Note: Modify the current user password
passwd [OPTION ...] <accountName> Note: Only the root user can modify other user passwords
Common options:
-D: Delete the password for the specified user;
-L: The password of the specified user;
-U: Unlocks the password of the specified user;
-E: Expires the specified user's password;
-F: Enforcement;
-X days: The maximum age of the password;
-N days: The minimum period of use of the password;
-W Days: The user is warned about the day before the password expires;
-I days: After the account has been disabled, the password expires in the day;
--stdin: Get the password from standard output.
(echo "PASSWD" |passwd--stdin USERNAME)
Modify User properties: Usermod syntax:
usermod [option] ... login
Common options:
-D Home_dir: Modify the user's home directory, the user's original files will not be moved to a new location;
-U uid: The UID used for modification;
-G Group: Modify the user's basic group;
-G GROUPS: Modify the user's additional groups, separated by commas between multiple groups, the original additional group will be overwritten;
-A: Used with-G to append a new additional group;
-M: can only be used with-D to move the original home directory to a new home directory;
-L New_login: Modify user name;
-S Shell: Modifies the user's default shell;
-L: Lock user account;
-U: Unlocks the user account.
Delete User: Userdel syntax:
Userdel [option] ... login
Common options:
-R: Delete the user's home directory and mailbox.
Add Group: Groupadd Syntax:
groupadd [option] ... GROUP
Common options:
-G gid: Specify GID;
-r: Create a system group.
Modify Group Properties: Groupmod Syntax:
groupmod [option] ... GROUP
Common options:
-G GID: Modify group GID;
-N new_group: Modifies the group name.
Delete Group: Groupdel syntax:
Groupdel [option] ... GROUP
Option: (not the same as)
Example: 1. Add a user test with the password set to 123456.
2. Add a group of Ubuntu, specifying a GID of 666.
Extension: Check to see if the add was successful.
3. Add an additional group to the test user Ubuntu.
4. Modify the test user's basic group to root.
Creation and management of Linux users and groups!