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)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay