Back to writing

genpass - bash password generator

A simple Bash script to generate strong random passwords with customizable options.

5 min read · Aug 27, 2025
Photo by Ilya Pavlov

Description

genpass is a simple Bash script for generating strong random passwords. It supports customizable password length, options to include numbers and symbols, and ensures that generated passwords always start and end with alphabetic characters to maintain compatibility with most systems.

Key features

Installation

  1. Save the script to a file, e.g., genpass.
  2. Make it executable:
    chmod +x genpass
  3. (Optional) Move it to a folder in your $PATH:
    sudo mv genpass /usr/local/bin/

Usage

General format

genpass [<length> <use_numbers> <use_symbols>]

Without arguments

The script will prompt for password length, number inclusion, and symbol inclusion interactively.

With arguments

Help option

genpass --help
or
genpass -h

Examples

  1. Interactive mode (uses defaults)
    genpass
  2. Generate a 16-character password with numbers and symbols
    genpass 16
  3. Generate a 16-character password with numbers but no symbols
    genpass 16 1 0

How it works

Input validation

License

Free to use, modify, and share.