linux:nice-to-know

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
linux:nice-to-know [2019/05/06 17:03] michaellinux:nice-to-know [2019/05/06 17:33] (current) michael
Line 155: Line 155:
 </WRAP> </WRAP>
  
 +----
 +
 +<WRAP center round box 100%>
 +''<wrap hi>**Generating a pseudorandom password or string in Linux bash**</wrap>''
 +
 +''Define a function in e.g. **~/.bashrc**''
 +
 +<sxh plain; gutter: false;>
 +genpasswd() {
 +  tr -dc A-Za-z0-9 < /dev/urandom | head -c ${1:-36} | xargs
 +}
 +</sxh>
 +
 +Where 36 is default length if no parameter is given
 +
 +----
 +
 +**Usage**:
 +
 +<code># genpasswd
 +GVQ3ZHqrBRDzB1QwASA9uk6YsZPto2GWeRWR
 +
 +# genpasswd 7
 +qvPWx7N</code>
 +</WRAP>
  
  • linux/nice-to-know.1557155024.txt.gz
  • Last modified: 2019/05/06 17:03
  • by michael