AcademyTerminal Tactics: Survival in the ShellPhase 6: Automatic Sentinels (Automation)

Lesson 7: The Power of Automation (Shell Scripting)

The true secret of a DevOps Engineer? Laziness.

We don't like doing the same task twice. If we have to do something more than once, we write a Script to do it for us.

What is a Shell Script?

It's just a file containing a list of Linux commands. When you run the file, Linux executes every line inside it, one by one.

The Components

  1. The Shebang (#!/bin/bash): The first line that tells Linux "this is a script".
  2. Permissions: You must give the file "Execute" (+x) permissions.
booting...

Mission Objective

Create your first automation.

  1. Create a file: touch hello.sh.
  2. Open it (we've pre-added some text for you).
  3. Make it runnable: chmod +x hello.sh.
  4. Run it: ./hello.sh.

Mission Control

Create a script file named hello.sh

Expected Command

touch hello.sh

Make it executable

Execute your script