Lion Cipher Lab
Write your first bash script
- Foundations
- Beginner
- ~35 min
- Free · no account required
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
- bash scripting
- shell variables
- script arguments
- if tests and for loops
- command substitution
- safe scripting habits
Steps in this lab
- A script is a file of commands — start with the shebang
- Make it executable, then run it (chmod +x)
- Variables — name a value once, and quote it
- Read arguments the script is given ($1)
- Capture a command's output (command substitution)
- Make a decision and repeat (if tests and for loops)
- Put it together: is this host up?
- The security habit: quote your variables, never pipe untrusted scripts into bash
- You can automate now — here's what that unlocks