Create random password in a shell script

Here’s a quick one-liner to make up a random password using only shell commands.
MYPASSWORD=`cat /dev/urandom | tr -dc a-z0-9 | head -c 10`
If you want to customize this a bit, there are two parts you can change, first is the filter which specified what range of characters are allowed in the password. a-z0-9 restricts the password to lower-case letters and digits only. You can add extra ranges and characters here, for example, to add a few punctuation characters, try a-z0-9$^&

The other customization is the length of the password which is the number at the end. In my case, the password will be 10 characters long, you can change it to anything you like.