Lion Cipher Lab

Write your first bash script

Why it matters

A script is just a file full of the commands you already type, saved so you can run them again with one word. That single idea is the difference between doing a task once by hand and doing it a hundred times without thinking. Nearly every hands-on security workflow — scanning a range of hosts, parsing a log, spinning up a target, collecting evidence — is a script underneath. Learn to write one and you stop repeating yourself and start automating.

What you'll learn

Steps in this lab

  1. A script is a file of commands — start with the shebang
  2. Make it executable, then run it (chmod +x)
  3. Variables — name a value once, and quote it
  4. Read arguments the script is given ($1)
  5. Capture a command's output (command substitution)
  6. Make a decision and repeat (if tests and for loops)
  7. Put it together: is this host up?
  8. The security habit: quote your variables, never pipe untrusted scripts into bash
  9. You can automate now — here's what that unlocks

Open the full interactive lab →