This is my mid-term Bash Project script, where I attempt to create a simple random password generator.
The "Random Password Generator" is a simple Bash script that helps you create strong, secure passwords in seconds. It gives you the option to customize the length, include special characters, and save passwords to a file for later use.
If you’ve ever struggled to come up with unique passwords or found yourself using the same ones over and over, this script is for you. Cybersecurity experts recommend using long, random passwords that are difficult to guess or crack. This script helps generate those secure passwords effortlessly.
Using weak or repeated passwords is one of the biggest risks to online security. Hackers can easily crack short or predictable passwords using brute-force attacks or dictionary attacks. This script ensures that each password is completely random, making it much harder for attackers to guess.
By regularly generating strong, unique passwords, you reduce your risk of unauthorized access to your accounts, data breaches, and identity theft. The ability to store passwords in a file also allows for safe password management, keeping them accessible but secure.
- Choose Password Length – Specify how long your password should be (default is 12 characters).
- Include Special Characters – Option to add symbols like !@#$%^&*() for extra strength.
- Save Passwords to a File – Store passwords in a file so you don’t lose them.
- Easy to Use – Simple commands make generating secure passwords quick and effortless.
- Error Handling – Prevents mistakes like using invalid inputs.
- Linux or macOS terminal (Windows users can use Git Bash or Windows Subsystem for Linux).
- No additional software needed—this script runs with built-in system tools.
Clone this repository using Git:
git clone https://github.com/bottskm45/BashProject/blob/main/RandomPasswordGenerator cd BashProject
Or manually download the script:
curl -O https://github.com/bottskm45/BashProject/blob/main/RandomPasswordGenerator/random_password_generator.sh chmod +x random_password_generator.sh
Run the script with the following options:
./random_password_generator.sh [-l length] [-s] [-o file]
| -l
| Set password length (default is 12) | -l 16
(Creates a 16-character password) |
| -s
| Include special characters (!@#$%^&*) | -s
(Adds symbols to the password) |
| -o
| Save password to a specified file | -o secure.txt
(Saves the password to secure.txt
) |
| -h
| Display help message | -h
(Shows usage instructions) |
./random_password_generator.sh
Output:
Generated Password: Ghd7PqkLzXc1 Password saved to passwords.txt
./random_password_generator.sh -l 20
./random_password_generator.sh -l 16 -s
./random_password_generator.sh -l 18 -s -o secure_pass.txt
By default, all generated passwords are automatically saved in a file called passwords.txt
. You can open it anytime to review your saved passwords:
cat passwords.txt
If you specify an output file with -o filename.txt
, the password is stored in that file instead.
- Stronger Security – Creates long, random passwords that are hard to crack.
- Convenience – Instantly generate and save secure passwords.
- No Dependencies – Works on any Linux/macOS system without extra software.
- Customizable – Adjust password length and characters as needed.
| Issue | Solution |
| "Command not found" | Make sure the script is executable: chmod +x random_password_generator.sh
|
| "Error: Length must be a number" | Ensure you're passing a valid number after -l
(e.g., -l 16
) |
| "Permission denied" | Try running with sudo
if necessary |
| Output is empty | Run ./random_password_generator.sh -l 12
and check if /dev/urandom
is accessible |
My name is Kaleb, a student at the University of Cincinnati, where I study cybersecurity. This little random password generator might be fun for those who dislike creating strong and unique passwords on their own.
Weak passwords are a serious risk in today’s digital world. This script makes it easy to generate strong, unique passwords that protect your accounts and sensitive information. Whether you're an IT professional, a cybersecurity student, or just someone who wants better security, this tool is a simple yet effective way to keep your passwords safe.