How to set / reset a Linux password within a script file

I had a need to setup a password within a script file.

Here is how I went about it:

echo “username:password” | chpasswd > /dev/null

Just replace the italicized username and password with the appropriate information.

Hope this helps!