Bash Tutorial · Bash Basics · Lesson 1 of 30

Bash Introduction

What Bash is, where you'll use it, and how the examples in this tutorial work.

Create a free account to save this page, take notes and track your progress. Sign in

What is Bash?

Bash (the Bourne Again SHell) is the command-line shell of most Linux systems and the language of countless scripts that build, test, deploy and operate software. A shell reads commands, runs programs, and connects them together; a shell script is a file of those commands that runs on its own.

You'll meet Bash everywhere:

  • Servers and containers: almost every Linux server and Docker image has a shell.
  • CI/CD pipelines: GitHub Actions, GitLab CI and Jenkins steps are mostly shell commands.
  • Developer tooling: setup scripts, Git hooks, Makefiles and one-off data clean-ups.
  • macOS and Windows: macOS uses zsh by default (very similar), and Windows has Bash through WSL.

How this tutorial works

Every example is a real Bash script that was run on Linux; the output shown is exactly what it printed. Each one starts in an empty directory, so examples create the files they need. Try them in a terminal: copy the code into a file such as demo.sh and run bash demo.sh.

Hello, Bash
echo "Hello from Bash!"
echo "Today we have $(ls / | wc -l) top-level directories on this machine"
name="developer"
echo "Welcome, $name"

Output

Hello from Bash!
Today we have 26 top-level directories on this machine
Welcome, developer

Run this on your computer — see “Get Started” for setup.

Test yourself

What is a shell script?

  1. A compiled binary
  2. A file of shell commands that runs as a program
  3. A configuration file for SSH
  4. A Python module
Show answer

Answer: A file of shell commands that runs as a program

Scripts automate what you'd otherwise type by hand.

Was this page helpful?