Create new Linux users with the useradd command
useradd username
The command adds an entry to /etc/passwd, /etc/shadow, /etc/group, and /etc/gshadow
Next, you need to set the user password. Type the following command
passwd username
If you add your users to the wheel group, they’ll have the power of a root user.
usermod -aG wheel username
You can verify that the user was created. Run the following command to show the user and group names and numeric IDs.
id username
The users’ and groups’ sudo privileges are configured in the /etc/sudoers file.
To display help, we type the following command
useradd –help
To set an expiry date for a specific user, you can use the usermod command followed by the -e flag, then the expiry date in yyyy-mm-dd format.
usermod -e 2024-10-08 username
Type the following command to verify if the expiration date is set correctly.
chage -l username
Delete user account. The -r option removes the home directory and mail spool of given user account.
userdel -r username
Verify that the user is successfully deleted
id username