DEV Community

Yaroslav Polyakov
Yaroslav Polyakov

Posted on

1

Shell oneliner to generate passwords

# 10 character random string from specified alphabet
< /dev/urandom tr -dc '[:graph:]' | head -c10; echo
Enter fullscreen mode Exit fullscreen mode

Bash allows redirections at any part of command, so < file command args above is same as command args < file.

Examples:

KrvJz?TgbO
T[7/9Lg9L9
bp[je2Og*l
93:m_Ss$z5
C}Z=-Nj-mn
mG<85C>!i~
%>7/]AWpMd
Enter fullscreen mode Exit fullscreen mode

If you do not want so many special characters, you may use something like: '[:alnum:]_$#%-'

JCPHawXEvr
orq#0S7cUk
82H7g_cHtY
um-#ACmny4
dYQFqGsX_d
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Immerse yourself in a wealth of knowledge with this piece, supported by the inclusive DEV Community—every developer, no matter where they are in their journey, is invited to contribute to our collective wisdom.

A simple “thank you” goes a long way—express your gratitude below in the comments!

Gathering insights enriches our journey on DEV and fortifies our community ties. Did you find this article valuable? Taking a moment to thank the author can have a significant impact.

Okay