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?
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.
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.