Loading
0x00Lesson 1 of 18

Meet the shell

Learn what a shell is, how a command is built, and how to get help without leaving the terminal.

18 min 7-question quiz 2 code exercises
By the end of this lesson you can
  • Explain how the terminal, the shell and the commands you run fit together
  • Break a command line into the command, its options and its arguments
  • Print text with echo and printf, and find help with type, help, man and --help

Welcome aboard Kestrel Station, a research outpost in low orbit. Every system up here - life support, cargo robots, the coffee machine - runs on Linux, and the crew talks to all of it through one tool: the shell. You’re the newest engineer, and by the end of this track you’ll be the one writing the scripts that keep the station humming.

Three pieces work together whenever you “use the command line”:

  • The terminal (Terminal, iTerm2, Windows Terminal, the panel in VS Code) is just a window that shows text and sends your keystrokes.
  • The shell is the program running inside it. It reads what you type, works out what you mean, runs programs, and shows their output.
  • Commands are the programs (and shell built-ins) that do the actual work: ls lists files, grep searches text, git manages code.

Bash - the Bourne Again SHell - is the most widely used shell. It’s the default on most Linux servers, in Docker containers and CI pipelines, and it’s one install away on macOS (whose default is now the very similar zsh) and Windows (Git Bash or WSL). Everything you learn here carries over to almost every shell you’ll meet.

Anatomy of a command

When the shell is ready, it shows a prompt - often something like ada@kestrel:~$. The $ means “type here”. (A # usually means you are the all-powerful root user, so be careful.) In lessons, a leading $ marks what you type; don’t type the $ itself.

A command line is a list of words separated by spaces. The first word is the command; the rest are passed to it:

1ls -l -a /etc
2│  │  │  └── argument: what to work on
3│  └──┴───── options (flags): how to do it
4└─────────── command

Short options start with one dash and can usually be combined (ls -la is ls -l -a). Long options start with two dashes and are spelled out (ls --all). Spaces matter: ls -la lists files, while ls - la asks for two files named - and la.

Try it

Command, option or argument?

Each item is one word from a command line (shown in brackets). Sort it into the role it plays.

0 of 7 sortedScore 0/0
  • “[ls] -la /home”

  • “ls [-la] /home”

  • “ls -la [/home]”

  • “grep [--count] ERROR station.log”

  • “grep --count ERROR [station.log]”

  • “grep --count [ERROR] station.log”

  • “[mkdir] -p logs/today”

Your first commands: echo and printf

echo prints its arguments separated by single spaces, then a newline. printf takes a format string first and fills its %s (string) and %d (whole number) placeholders with the remaining arguments - and it only adds a newline where you write \n. These examples run for real: press Run, then Edit and experiment.

hello.sh
1echo Hello, Kestrel!
2echo "Spaces    inside quotes    are kept"
3echo Spaces    outside    quotes    are    not
4printf '%s has %d crew aboard\n' Kestrel 6
5printf '%-10s|%5s|\n' left right
Output
Hello, Kestrel!
Spaces    inside quotes    are kept
Spaces outside quotes are not
Kestrel has 6 crew aboard
left      |right|

Notice line 3: the shell splits the line into words at any run of spaces before echo ever sees it, so echo receives five tidy words and joins them with single spaces. Quotes keep text together as one word. You’ll lean on that idea constantly. In printf, %-10s pads a string to 10 characters, left-aligned, and %5s right-aligns it in 5 - perfect for tables.

Getting help

Nobody memorizes every option. Experienced engineers look things up constantly - from the terminal itself:

CommandWhat it tells you
type lswhat a name is: a built-in, a program on disk, an alias or a function
help cdthe manual for a Bash built-in (like cd, echo, read)
man lsthe full manual page for a program (press q to quit, /word to search)
ls --helpa quick summary that most GNU programs print

Some handy keys: Tab completes names, ↑ recalls earlier commands, Ctrl+R searches your history, Ctrl+C cancels the running command, and Ctrl+L clears the screen.

what-is-it.sh
1type echo
2type cd
3type -t grep
4whoami
Output
echo is a shell builtin
cd is a shell builtin
file
wandbox

Key takeaways

  • The terminal shows text; the shell interprets your commands; commands do the work.

  • A command line is split into words: the command, then options (starting with - or --), then arguments.

  • echo prints its words; printf gives precise control with a format string and %s/%d placeholders.

  • Use type, help, man and --help to find out what something is and how to use it.

Lesson quiz

7 questions · pass with 5 correct · up to 50 XP

Passing this quiz completes the lesson and keeps your streak going. Questions you miss come back in review sessions later.

Practice: write Bash scripts

Write a script in the editor and run it for real against sample input. Each run gets a fresh Linux sandbox with Bash 5.2 and the GNU tools on Wandbox, a free public service - so experiment freely, even with rm. Your script and test input are sent there.

Exercise 1

Print the station banner

+25 XP

Print exactly these three lines:

=== KESTREL STATION ===
Orbit: low
Crew: 6
  • Prints the banner
script.sh
Loading editor…

Your script runs with Bash 5.2 and GNU tools on Wandbox, a free public service, in a fresh sandbox each time. Your script and test input are sent to that service.

Exercise 2

Line up the supply table

+25 XP

Use printf to print a table of supplies. Each row is the item left-aligned in 8 characters, a space, then the amount right-aligned in 4:

water     120
oxygen     87
coffee      3

One printf call with a single format string and six arguments can print all three rows.

  • Prints an aligned table
script.sh
Loading editor…

Your script runs with Bash 5.2 and GNU tools on Wandbox, a free public service, in a fresh sandbox each time. Your script and test input are sent to that service.

Questions about this lesson

Stuck? Ask. Figured something out? Share it. Explaining is one of the best ways to learn.

Loading posts…

Did you like the lesson? 😆👍
Consider a donation to support our work: