Adding new users to Linux, creating new users, creating new accounts
Add User Group
sudo groupadd groupname
Add user
sudo useradd username-m-s/sbin/nologin-d/home/username-g groupname
-s/sbin/nologin settings can not log-s/bin/false (old method) also OK
-D Set User home directory
-G user Group
-M Create user Directory
The specific parameters of Useradd are
[root@317304 ~]# Useradd--help
Usage:useradd [Options] LOGIN
Options:
-B,--base-dir base_dir base directory for the home directory of the
New Account
-C,--comment comment GECOS field of the new account
-D,--home-dir home_dir home directory of the new account
-D,--defaults print or change default Useradd configuration
-E,--expiredate expire_date expiration DATE of the new account
-F,--inactive inactive password inactivity period of the new account
-G,--gid group name or ID of the primary group of the new
Account
-G,--groups groups list of supplementary groups of the new
Account
-H,--help display this help message and exit
-K,--skel Skel_dir Use this alternative skeleton directory
-K,--key key=value override/etc/login.defs defaults
-L,--no-log-init do don't add the user to the Lastlog and
Faillog databases
-M,--create-home create the user ' s home directory
-M,--no-create-home do not create the user's home directory
-N,--no-user-group do don't create a group with the same name as
The user
-O,--non-unique allow to create the users with duplicate
(Non-unique) Uid
-p,--password password encrypted password of the new account
-R,--system create a System account
-S,--shell Shell login shell of the new account
-U,--uid uid user ID of the new account
-U,--user-group create a group with the same name as the user
-Z,--selinux-user seuser use a specific seuser for the SELinux user mapping
Change user logon rights
After adding the-s/sbin/nologin parameter, then this account cannot log in, if want to restore login to use
sudo usermod-s/bin/bash username
Disable user logon rights
sudo usermod-s/sbin/nologin username
Set Password
Set a password for the user so that the account can be used.
sudo passwd username
Delete User
sudo userdel username