command line to set a password to a new userid
I need to write a script to create a new userid in a Linux environment.
That's done. Now i like to set a password for this userid, note that i want to do it in a script , not from a command line.
useradd -d /home/mht mht
I used crypt to create a new password and used the command:
usermod -p "encrypted password" mht.
This doesn't work. I saw in the /etc/shadow , other id has encrypted password starting with $. I guess my password is from crypt so it won't work. How do i encrypt my password so it can be copied to the command usermod -p.