useradd command

LINUX-Frequently used commands

useradd command Adding a new user.
Syntax
useradd  [Option]  [Path]
The useradd command is used to add a new user.
When a user is added, a directory with the specified user name is created under the /home directory, and this directory becomes the home directory for the added user.
This information is stored in the /etc/passwd file, and information about groups is stored in the /etc/group file.
The command is executed with the user name as an argument.
Frequently used options
-c  <comment>          Enter a comment for a new user
-d  <directory>     Specify your home directory explicitly
-e  <yyyymmdd>      Specify the expiry date of the user account (date)
-g  <group>             Specify the group to which you belong.
Example: Adding a user.
$ su -  ← Become root with the su command
Password:    Enter root password
# useradd koro  ←  Add user "koro".
Example: Adding a user by specifying their home directory.
$ su -  ← Become root with the su command
Password:    Enter root password
# useradd  -d  /home/buy  koro  ← Add user 'koro' to your home directory '/home/buy'
Example: Add a new user with an expiry date.
$ su -  ← Become root with the su command
Password:    Enter root password
# useradd -e 20211231 koro    ← Addition of the user "koro" with a deadline until 31 December 2021
Copied title and URL