I need to have the ability to create user accounts on my Linux (Fedora 10) and automatically assign a password via a bash script(or otherwise, if need be).
It\'s eas
I liked Tralemonkey's approach of echo thePassword | passwd theUsername --stdin
though it didn't quite work for me as written. This however worked for me.
echo -e "$password\n$password\n" | sudo passwd $user
-e
is to recognize \n
as new line.
sudo
is root access for Ubuntu.
The double quotes are to recognize $
and expand the variables.
The above command passes the password and a new line, two times, to passwd
, which is what passwd
requires.
If not using variables, I think this probably works.
echo -e 'password\npassword\n' | sudo passwd username
Single quotes should suffice here.