Loading

Learn Bash

Command the shell: navigate, wrangle text and automate anything with scripts.

Start learning 18 lessons · about 8 hours · free
About this track

The shell is the oldest power tool in computing that’s still used every day. Servers, containers, CI pipelines and developer laptops all speak it, and a three-line script can save you an afternoon of clicking.

You’re the newest engineer aboard Kestrel Station, an orbital outpost run entirely on Linux. You’ll find your way around the filesystem, set permissions, plumb commands together with pipes, search and reshape logs with grep, sed and awk, then write real scripts with variables, conditions, loops, functions and arrays - and make them robust with strict mode, traps and option parsing. Along the way you’ll build pipelines stage by stage, step through how Bash expands a command line, and flip permission bits. Every example and exercise runs in a real Bash 5.2 sandbox, and the capstone has you write the station’s log report tool.

Before you start
  • No command-line experience is required.
  • A modern browser with JavaScript enabled. To practice locally, use a terminal on Linux or macOS, or Git Bash or WSL on Windows.
  1. Unit 1 · 0/4 lessons

    Shell foundations

    Run commands, move around the filesystem, manage files and set permissions. Badge: Prompt tamer

    1. 0x001Meet the shellLearn what a shell is, how a command is built, and how to get help without leaving the terminal. 18 min 0/2 exercises solved 18 min 0/2 exercises solved
    2. 0x102Navigate the filesystemMove around the directory tree with pwd, ls and cd using absolute and relative paths. 20 min 0/2 exercises solved 20 min 0/2 exercises solved
    3. 0x203Create, copy, move and deleteMake files and directories, peek inside them, and use wildcards and braces to handle many at once. 25 min 0/2 exercises solved 25 min 0/2 exercises solved
    4. 0x304Permissions and ownershipRead ls -l, understand read, write and execute for owner, group and others, and change them with chmod. 20 min 0/2 exercises solved 20 min 0/2 exercises solved
  2. Unit 2 · 0/5 lessons

    Streams and pipelines

    Redirect streams, chain filters with pipes, and search and reshape text with grep, sed, awk and find. Badge: Pipe fitter

    1. 0x405Redirection and streamsSend output to files, read input from them, keep errors apart, and write files with heredocs. 22 min 0/2 exercises solved 22 min 0/2 exercises solved
    2. 0x506Pipelines and filtersChain small tools with | to sort, count, slice and transform text in one line. 28 min 0/2 exercises solved 28 min 0/2 exercises solved
    3. 0x607Search with grep and regular expressionsFind lines that match patterns, from exact words to precise regular expressions. 26 min 0/2 exercises solved 26 min 0/2 exercises solved
    4. 0x708Edit streams with sed and awkFind-and-replace with sed, and process columns, totals and conditions with awk. 28 min 0/2 exercises solved 28 min 0/2 exercises solved
    5. 0x809Find files and act on themSearch directory trees by name, type, size and age with find, and feed the results to other commands. 22 min 0/2 exercises solved 22 min 0/2 exercises solved
  3. Unit 3 · 0/4 lessons

    Scripting fundamentals

    Write scripts with variables, quoting, expansions, conditions and loops. Badge: Script writer

    1. 0x9010Write your first scriptSave commands in a file, store values in variables, quote them correctly, and read arguments and input. 25 min 0/2 exercises solved 25 min 0/2 exercises solved
    2. 0xA011How Bash expands a command lineFollow Bash’s expansion steps, slice strings with parameter expansion, and use command substitution and arithmetic. 30 min 0/2 exercises solved 30 min 0/2 exercises solved
    3. 0xB012Exit codes and conditionsUse exit statuses, && and ||, if with [[ ]] and (( )), and case to make decisions. 28 min 0/2 exercises solved 28 min 0/2 exercises solved
    4. 0xC013LoopsRepeat work with for, while and until, and process files and input line by line. 26 min 0/2 exercises solved 26 min 0/2 exercises solved
  4. Unit 4 · 0/4 lessons

    Robust scripts

    Organize scripts with functions and arrays, manage processes, and make scripts fail safely. Badge: Automation smith

    1. 0xD014FunctionsPackage reusable steps as functions with arguments, local variables, return statuses and output. 24 min 0/2 exercises solved 24 min 0/2 exercises solved
    2. 0xE015Arrays and associative arraysStore lists in indexed arrays and key-value pairs in associative arrays. 24 min 0/2 exercises solved 24 min 0/2 exercises solved
    3. 0xF016Processes and the environmentUnderstand environment variables and PATH, subshells, background jobs, and signals. 26 min 0/2 exercises solved 26 min 0/2 exercises solved
    4. 0x10017Write robust scriptsMake scripts fail safely with strict mode, clean up with traps, parse options with getopts, and debug. 30 min 0/2 exercises solved 30 min 0/2 exercises solved
  5. Unit 5 · 0/1 lessons

    Capstone

    Build the station’s log report tool from pipelines, loops, arrays and strict mode. Badge: Log whisperer

    1. 0x11018Capstone: the station log reportCombine pipelines, loops, associative arrays, functions and strict mode into a real reporting tool. 45 min 0/3 exercises solved 45 min 0/3 exercises solved
Did you like the lesson? 😆👍
Consider a donation to support our work: