1

I need to create a user with password in a shell script, but passwd wants me to enter the password twice. Is there a way to create a user with password in one command?

1

You can use this command.

echo -e "password\password\n\n\n\n\n\n\n\n"|adduser username

Please replace the 'password' with the desired password and 'username' with the username you need to create.

Regards, Ajo

0

If you want to create a user in a shell script, you should use useradd -p which takes the encrypted form of the password. That way, you don't have have the password in cleartext.

Note that on debian, users are normally added with adduser, which has various bits of policy configured in /etc/adduser.conf. useradd is the "raw" command, so you need to take care to get group membership and homedir permissiones as you expect them.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.