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
- The Shebang (
#!/bin/bash): The first line that tells Linux "this is a script". - Permissions: You must give the file "Execute" (
+x) permissions.
booting...
Mission Objective
Create your first automation.
- Create a file:
touch hello.sh. - Open it (we've pre-added some text for you).
- Make it runnable:
chmod +x hello.sh. - Run it:
./hello.sh.