Bash Intro
Linux is the operating system that runs most of the world's servers, cloud machines, containers, Android phones and many developer laptops. Bash (the Bourne Again SHell) is the program that reads the commands you type in a Linux terminal and runs them. Learning Bash means learning to talk to a computer directly: listing and moving files, searching logs, chaining small tools together and automating repetitive work with scripts.
Why learn the command line?
| Reason | Example |
|---|---|
| Servers have no desktop | You manage a cloud machine over ssh, with only a shell |
| Automation | A 10-line script renames 5,000 photos or backs up a folder every night |
| Composable tools | grep, sort and uniq combine into a log analyser in one line |
| DevOps | Dockerfiles, CI pipelines and Kubernetes jobs are full of shell commands |
| Speed | Many tasks take one command instead of dozens of clicks |
Your first commands
A command is a program name, optionally followed by arguments. echo prints its arguments, whoami prints your user name and pwd prints the directory you are in:
echo "Hello from Bash!"
whoami
pwdHello from Bash!
learner
/home/learner
Every example in this course runs on a real Linux machine as the user learner, starting in the empty home directory /home/learner. The examples you see are short scripts: Bash reads them line by line, exactly as if you had typed each line at the prompt.
The prompt
In an interactive terminal Bash shows a prompt before each command, usually something like:
learner@tad:~$ echo hi
hi
learner@tad:~$It tells you the user (learner), the machine's host name (tad), the current directory (~ is short for your home directory) and $ for a normal user (# for the administrator, root). In this course the prompt is left out of runnable examples; when a session is shown with prompts, don't type the $.
Commands, options and arguments
Most commands follow the same pattern:
command -options arguments
ls -a /etcOptions (also called flags) change how a command behaves. Short options are a dash and one letter (-a), and several can be combined (-la is -l -a). Long options use two dashes (--all). Arguments are what the command works on: file names, text, numbers.
echo one two three
printf '%s\n' apples pears
date -d 2026-03-01 +%A
expr 6 \* 7one two three
apples
pears
Sunday
42
date -d formats a fixed date here; plain date would print the current time, which changes every run.
Getting help
You never have to memorise every flag. Three ways to find out what a command can do:
| Command | What it shows |
|---|---|
man ls |
The full manual page (press q to quit) |
ls --help |
A short summary of options (most GNU tools) |
help cd |
Help for Bash built-ins such as cd, echo, read |
type ls |
Whether a name is a built-in, an alias or a program on disk |
type cd
type echo
help pwd | head -n 3cd is a shell builtin
echo is a shell builtin
pwd: pwd [-LP]
Print the name of the current working directory.
Built-ins are part of Bash itself; other commands are separate programs stored in directories such as /usr/bin.
Shells and terminals
The terminal (GNOME Terminal, Windows Terminal, iTerm2, the VS Code panel) is the window that shows text. The shell is the program running inside it. Bash is the default shell on most Linux distributions; macOS now defaults to zsh, which is very similar for everyday use. Windows users can get a real Bash through WSL (Windows Subsystem for Linux) or Git Bash.
Tip: Press Tab to auto-complete commands and file names, ↑ to recall earlier commands and Ctrl+C to stop a running command. These three keys save more time than anything else.
What you'll learn
- Basics: syntax, scripts, and the everyday file commands (
ls,cd,cp,mv,rm,grep,find,tar…). - Text processing:
sed,awk,cut,sort,uniq,tr,xargsand friends. - Scripting: variables, quoting, arrays, conditions, loops, functions, arguments and robust error handling.
- The Linux system: permissions, users, processes, the filesystem layout, packages, scheduled jobs and shell configuration.
Test yourself
What is Bash?
- A text editor
- A shell: a program that reads and runs commands
- A Linux distribution
- A terminal window
In ls -a /etc, what is -a?
- An argument
- An option (flag)
- The command
- A variable
Which command tells you whether cd is a built-in or a program on disk?
- man cd
- which cd
- type cd
- help