Script Valley
Bash Scripting for Developers
Shell FundamentalsLesson 1.1

What is Bash and why developers use it

shell vs terminal, Bash vs sh vs zsh, Unix philosophy, shebang line, script execution model, PATH variable

Bash Is a Program, Not Magic

Bash execution model

Bash (Bourne Again SHell) is just a program that reads commands โ€” from your keyboard or a file โ€” and tells the operating system to execute them. When you open a terminal, you're launching a Bash process. Everything you type gets parsed, evaluated, and handed to the kernel.

Other shells exist: sh (original POSIX shell), zsh (macOS default since Catalina), fish. Bash is the DevOps standard because it's available on virtually every Linux server.

The Shebang Line

The first line of every Bash script tells the OS which interpreter to use:

#!/usr/bin/env bash
echo "Hello, developer"

#!/usr/bin/env bash is preferred over #!/bin/bash because env finds Bash wherever it's installed โ€” important for portability across macOS and Linux.

Running Your First Script

# Create the file
echo '#!/usr/bin/env bash
echo "Hello, developer"' > hello.sh

# Make it executable
chmod +x hello.sh

# Run it
./hello.sh

The ./ prefix is required because the current directory isn't in PATH by default โ€” a deliberate security decision. Without it, Bash won't find your script even if you're sitting in the same folder.

Scripts run in a subshell: a child process forked from your terminal. Changes to variables or the working directory inside the script don't affect your current shell session.

Up next

Bash variables and quoting rules explained

Sign in to track progress

What is Bash and why developers use it โ€” Shell Fundamentals โ€” Bash Scripting for Developers โ€” Script Valley โ€” Script Valley