Good question 👍 In Bash, you can generate random values using the special variable $RANDOM.
Here’s how it works:
echo $RANDOM- Outputs a random number between 0 and 32767.
- Example:
19382
echo $(( RANDOM % 100 )) # 0–99
echo $(( (RANDOM % 50) + 1)) # 1–50for i in {1..5}; do
echo $RANDOM
donetr -dc 'A-Za-z0-9' </dev/urandom | head -c 12- Generates a 12-character random string like
aK3dP9xTq7Wc.
PASSWORD=$(tr -dc 'A-Za-z0-9!@#$%^&*()_+=' </dev/urandom | head -c 16)
echo $PASSWORD- Example output:
G7@h2Kp9!xD4LmQz - Good for secure auto-generated passwords.
⚡ In your user creation script, instead of:
PASSWORD=$(date +%s%N)You can use:
PASSWORD=$(tr -dc 'A-Za-z0-9!@#$%^&*()_+=' </dev/urandom | head -c 12)That way each new user gets a random, strong password.
Do you want me to replace your password generation line in the script with this stronger random password generator?