you need to learn BASH Scripting RIGHT NOW!! // EP 1
Based on NetworkChuck's video on YouTube. If you like this content, support the original creators by watching, liking and subscribing to their content.
Bash scripting packages command-line commands into a file so they run automatically instead of being typed repeatedly.
Briefing
Bash scripting is framed as a practical superpower for anyone aiming to level up in Linux-heavy careers—automation for cloud work, network tasks, and day-to-day command-line chores. The core message is simple: bash is both the Linux command-line “shell” (born again shell) and a scripting language that lets people package repeated commands into a file so they run automatically. That shift—from typing commands one by one to running a script—turns basic terminal use into something closer to engineering.
The episode starts by defining bash as the standard way to interact with the Linux operating system through a shell that sits around the kernel, sparing users from low-level complexity. From there, it positions bash scripting as “automating what’s typed in the shell.” To make the learning immediate, it walks through setting up a Linux lab environment using Linode, including creating a cheap virtual machine (with a shared CPU choice) and connecting via SSH from Windows CMD or a terminal on macOS/Linux.
Once inside the bash shell, the transcript demonstrates verification using the command `echo $SHELL`, which prints the active shell and confirms the environment. Then it moves straight into a first script: printing a greeting. The example uses the `echo` command to say “Hi mom,” first manually in the terminal and then inside a script file created with `nano`.
The script file is named `hi mom.sh`, and the transcript emphasizes two critical conventions. First, the file begins with a shebang line: `#!/bin/bash`, which tells the system to run the script using the bash interpreter. Second, the script body contains the command(s) to automate—here, `echo "Hi mom"`.
After saving and confirming the file exists with `ls`, the script is run in two ways. The primary method is `bash hi mom.sh`, which explicitly invokes bash to execute the script. A second method—`./hi mom.sh`—is introduced as a shortcut that requires the script to have executable permission.
That leads to the episode’s key troubleshooting lesson: “permission denied” happens when the file lacks execute rights. The transcript shows how to inspect permissions using `ls -l`, interpreting the permission string where the execute bit is missing (no `x`). The fix uses `chmod +X hi mom.sh` to add executable permission, after which `./hi mom.sh` runs successfully.
To demonstrate that scripts can do more than one command, the transcript edits the script again and adds `sleep` delays and additional `echo` lines, creating a short back-and-forth greeting sequence. The episode closes by reinforcing the big takeaway: a bash script is essentially a bundle of command-line commands that runs automatically, and mastering it unlocks increasingly powerful automation over subsequent episodes.
Cornell Notes
Bash scripting turns repeated command-line actions into an executable file, letting Linux do tasks automatically. Bash is the standard Linux shell and also a scripting language; scripts start with a shebang line `#!/bin/bash` so the system knows which interpreter to use. The episode builds a first script that uses `echo` to print “Hi mom,” then expands it with `sleep` and more `echo` commands. Running scripts can be done either with `bash script.sh` or with `./script.sh`, but the latter requires executable permission. When `./script.sh` fails with “permission denied,” `ls -l` reveals missing execute bits and `chmod +X script.sh` fixes it.
What does bash scripting change about how people work in Linux?
How does Linux know a script should run under bash?
What’s the difference between running `bash hi mom.sh` and `./hi mom.sh`?
How can someone diagnose and fix “permission denied” for a script?
What commands were used to make the first script do more than one action?
Review Questions
- Why is the shebang line `#!/bin/bash` important, and what could go wrong if it’s missing?
- When would you choose `bash script.sh` instead of `./script.sh`?
- What does `chmod +X` change, and how would you confirm the change with `ls -l`?
Key Points
- 1
Bash scripting packages command-line commands into a file so they run automatically instead of being typed repeatedly.
- 2
Bash is both the Linux shell interface and a scripting language; scripts should start with `#!/bin/bash` to select the bash interpreter.
- 3
A first script can be as simple as `echo "Hi mom"` inside `hi mom.sh`.
- 4
Scripts can be run with `bash hi mom.sh` (explicit interpreter) or `./hi mom.sh` (requires executable permission).
- 5
“Permission denied” when using `./script.sh` usually means the execute bit is missing; confirm with `ls -l`.
- 6
Use `chmod +X hi mom.sh` to add executable permission, then rerun the script with `./hi mom.sh`.
- 7
Adding commands like `sleep` lets scripts perform timed sequences, not just single outputs.