Get AI summaries of any video or article — Sign up free
you need to learn BASH Scripting RIGHT NOW!! // EP 1 thumbnail

you need to learn BASH Scripting RIGHT NOW!! // EP 1

NetworkChuck·
4 min read

Based on NetworkChuck's video on YouTube. If you like this content, support the original creators by watching, liking and subscribing to their content.

TL;DR

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?

It replaces manual, one-by-one command entry with an automated script file. Instead of typing `echo "Hi mom"` repeatedly in the shell, the commands are written into `hi mom.sh` and then executed in one step, so the same actions run consistently and faster.

How does Linux know a script should run under bash?

The script begins with a shebang line: `#!/bin/bash`. That line tells the system to use the bash interpreter for the commands inside the file, which matters when scripts might otherwise be run with the wrong language.

What’s the difference between running `bash hi mom.sh` and `./hi mom.sh`?

`bash hi mom.sh` explicitly invokes bash to run the script, so executable permission isn’t required. `./hi mom.sh` relies on the file being marked executable; otherwise the system returns “permission denied.”

How can someone diagnose and fix “permission denied” for a script?

Use `ls -l` to inspect permissions. The permission string includes read/write/execute bits; if the execute bit is missing (no `x`), the script can’t be run via `./`. Fix it with `chmod +X hi mom.sh`, then re-check with `ls -l` and run `./hi mom.sh`.

What commands were used to make the first script do more than one action?

The script uses `echo` to print messages and `sleep` to pause between them. After editing in `nano`, the script can output a sequence like greetings, waits, and a closing line, all without manual typing.

Review Questions

  1. Why is the shebang line `#!/bin/bash` important, and what could go wrong if it’s missing?
  2. When would you choose `bash script.sh` instead of `./script.sh`?
  3. What does `chmod +X` change, and how would you confirm the change with `ls -l`?

Key Points

  1. 1

    Bash scripting packages command-line commands into a file so they run automatically instead of being typed repeatedly.

  2. 2

    Bash is both the Linux shell interface and a scripting language; scripts should start with `#!/bin/bash` to select the bash interpreter.

  3. 3

    A first script can be as simple as `echo "Hi mom"` inside `hi mom.sh`.

  4. 4

    Scripts can be run with `bash hi mom.sh` (explicit interpreter) or `./hi mom.sh` (requires executable permission).

  5. 5

    “Permission denied” when using `./script.sh` usually means the execute bit is missing; confirm with `ls -l`.

  6. 6

    Use `chmod +X hi mom.sh` to add executable permission, then rerun the script with `./hi mom.sh`.

  7. 7

    Adding commands like `sleep` lets scripts perform timed sequences, not just single outputs.

Highlights

Bash scripting is presented as automation: write the commands once, then run them repeatedly as a script.
The shebang `#!/bin/bash` is the switch that tells the system which interpreter to use.
Executable permission is the gatekeeper for `./script.sh`; `chmod +X` is the fix.
A minimal bash script can be built from `echo`, then expanded with `sleep` and additional `echo` lines for multi-step behavior.

Topics

  • Bash Scripting Basics
  • Linux Shell
  • Shebang Line
  • File Permissions
  • Automation

Mentioned