Some handy CLI tricks I use daily:

Check SSL certificate expiry:

echo | openssl s_client -connect example.com:443 2>/dev/null | openssl x509 -noout -dates

Monitor a webpage for changes:

watch -d -n 300 "curl -s https://example.com/ | md5sum"

Generate a QR code from terminal:

qrencode -t UTF8 "https://your-url.com/"

Quick JSON formatting:

echo "{\"key\":\"value\"}" | python3 -m json.tool

Decode a JWT token:

echo "your.jwt.token" | cut -d. -f2 | base64 -d 2>/dev/null | jq .

If you want these as quick web tools (useful when SSHd into a box without these packages), I threw together a free API toolkit that does all of this over HTTP: JSON formatting, JWT decoding, QR generation, UUID gen, hashing, etc.

What are your go-to one-liners?

  • treadful@lemmy.zip
    link
    fedilink
    English
    arrow-up
    1
    ·
    39 minutes ago

    Piping nothing into openssl to get it to not keep the connection open is neat.

  • Ephera@lemmy.ml
    link
    fedilink
    English
    arrow-up
    5
    ·
    4 hours ago

    So, uh, if you’re already using jq, this should also format JSON:

    echo "{\"key\":\"value\"}" | jq
    

    😅

    • devtoolkit_api@discuss.tchncs.deOP
      link
      fedilink
      arrow-up
      3
      ·
      2 hours ago

      Ha, you’re absolutely right — jq alone handles formatting perfectly. I tend to use python3 -m json.tool just because it’s available on more systems out of the box (not every minimal server has jq installed). But yeah, if jq is there, it’s the better tool for sure.