Skip to content

Instantly share code, notes, and snippets.

@dukenmarga
Created November 8, 2022 13:46
Show Gist options
  • Save dukenmarga/1d75f3f880b362c791a2609f8bd272fe to your computer and use it in GitHub Desktop.
Save dukenmarga/1d75f3f880b362c791a2609f8bd272fe to your computer and use it in GitHub Desktop.
List of Useful Linux Commands

Generate Random String

Source

# Method 1: md5 Hash
echo $RANDOM | md5sum | head -c 20; echo;
996e405cb0cdd2e10299

# Method 2: UUID
cat /proc/sys/kernel/random/uuid | sed 's/[-]//g' | head -c 20; echo;
c23174ce6fa149498fc7

# Method 3: Pseudo devices
cat /dev/urandom | tr -dc '[:alpha:]' | fold -w ${1:-20} | head -n 1
qGswsbBusuztUEKXhiHu

cat /dev/urandom | tr -dc '[:alpha:]' | fold -w ${1:-20} | head -n 5
POzxNTvFtNQqjzgJFwou
RaZpkKDCWIvzAxaCraMu
BldZwyUIYWZPFnMiMETl
CxVFKmAoGBEZysLqzORo
YoXTcgLzXdnoEzoMwmFa

# Method 4: Base64
echo $RANDOM | base64 | head -c 20; echo
MTM2ODEK

# Method 5: OpenSSL Pseudo Random Bytes
openssl rand -hex 20
1dba62137447861b2b2eb81e5886fa98d021007b

openssl rand -base64 21
i05hHQeajBZcZerx/FtPtJH4XYUd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment