Bash › Linux Fundamentals

The shell, the terminal, and your first script

4 min read Beginner 6 sections

Bash is the language of the Linux environment itself — the glue that chains together every tool you already use. The goal here isn’t to replace Python or your Go tooling. It’s to chain and automate them: pipe one tool into another, filter the output, and turn a manual checklist into a one-liner. Most of the value in this whole course is in the pipelines, not any single command.

Let’s start with what you’re actually typing into.

You'll learn to

  • Tell the terminal and the shell apart
  • Write a script with a correct shebang line
  • Run the four-command situational-awareness reflex

Terminal vs shell

The terminal is the window. The shell is the program running inside it that interprets your commands. bash (the Bourne Again Shell) is the default on almost every Linux system, and it’s the language of this course.

When you type a command and press Enter, bash reads it, finds the program, runs it, and shows the output. A Bash script is simply a file full of those commands that bash executes top to bottom.

#!/usr/bin/env bash
# The shebang line above tells the system which interpreter to use.
# Without it, the system might run your script with a less capable shell, or fail.

echo "hello"          # echo prints text to the screen
pwd                   # print working directory — where am I?
whoami                # which user am I?
id                    # uid, gid, and all my groups — my privilege context

The shebang is not optional

That first line — #!/usr/bin/env bash — is mandatory in every script you write. It tells the operating system “run this file with bash.” Using env bash rather than hardcoding /bin/bash is portable, because bash lives in different places on different systems.

Your first reflex on any system

id is your constant companion. It shows your exact privilege context instantly — your user, your groups, whether you’re root.

A mistake that wastes hours

# WRONG — bash reads this as a command called 'VAR':
VAR = "value"

# RIGHT — no spaces around the equals sign:
VAR="value"

Try it yourself

Create a file called recon.sh with the shebang line, then add id, hostname, and uname -a on separate lines. Run chmod +x recon.sh and then ./recon.sh. You’ve just written your first situational-awareness script.

Summary

The terminal is the window; the shell (bash) interprets your commands. A script is a file of commands run top to bottom, and it must start with a shebang (#!/usr/bin/env bash). The id/whoami/hostname/uname -a reflex is how you orient on any system. And never put spaces around = in an assignment.

Key takeaways

  • The shell interprets commands; bash is the default shell.
  • Every script starts with #!/usr/bin/env bash.
  • chmod +x plus the shebang lets you run ./script.sh.
  • NAME=value with no spaces — the number-one beginner trap.

Quick quiz

Next, we map the Linux file system from a security angle — the directories where secrets, logs, and privilege-escalation paths actually live.

Was this lesson helpful?