setting password for a user with adduser command

0

Regarding the useradd command, there is an option -p for setting the password. But, it seems that it doesn't work and I have to later enter passwd command.

useradd -d /export/home/au -G users -p 123456 -s /bin/bash au

Also, there is a minor question. I want to redirect the default /home/au to /export/home/au. Should I use -m or not?

mahmood

Posted 2016-03-16T10:49:44.423

Reputation: 655

Answers

2

the -p switch doesn't set the password directly, it sets an encrypted password as returned by the crypt function call. It is also disabled by default, as anyone listing the process (or who can later retrieve your bash history) can see the password you entered.

Regarding the -m switch, this only tells useradd to create the home directory if it doesn't already exist. Personally I've never used it, as CREATE_HOME is set to yes on all of my servers, and if the same is the case for you, then you won't need it.

Jarmund

Posted 2016-03-16T10:49:44.423

Reputation: 5 155