Create New User with Temporary Password on Linux

  1. Create new user and home directory
> useradd -m USERNAME

-m option is used to create the user’s home directory if it does not exist.

If you want to specify the path of the home directory, use -d and specify the path:

> useradd -m -d /PATH/TO/FOLDER USERNAME
  1. Set temporary password for new user
> passwd USERNAME
  1. Change password expiration information
> chage -d 0 USERNAME

-d option is used to set the number of days since January 1st, 1970 when the password was last changed.

After previous three steps, you can email username and temporary password to user. User will be asked to change password for the first time.

More details of commands and their options can be checked by man command, like using

> man chage

to check all of information of chage command.

Recommended Posts