Skip to content

Guide · Open source

How to use bash-guide: learn common bash commands by example

Updated · written with AI from the project's own documentation and checked against our catalogue data

bash-guide is an open-source, read-online guide to the bash shell, the command-line program common on Linux and macOS. It covers everyday commands for listing, copying, searching and compressing files, then basic scripting topics such as variables, loops, functions and pipes. This page explains how to get the guide, what it covers, and how to practise the examples so you can use them yourself after reading.

bashIdnan/bash-guide · ★ 12.5k · MIT

Quick start

  1. 1Clone the repository. Run git clone on the Idnan/bash-guide repository to get a local copy of the guide.
  2. 2Open the README. Read the table of contents and choose the section you need, such as file operations or text operations.
  3. 3Create a scratch folder. Make a test directory so you can run commands without risk to your real files.
  4. 4Run each example. Type the command shown in the entry and compare your output with the sample output.
  5. 5Try text tools. Practise awk with the -F option on a file such as /etc/passwd to see how fields are split.
  6. 6Move to scripting. Work through variables, loops, conditionals and functions in the second half of the guide.

What do you need before you start?

The guide is read online, and the source README lists no prerequisites. However, its examples assume a Unix-like shell, so you need a terminal on a Linux or macOS system, or a bash environment on Windows. Windows users without one will find the examples do not apply directly.

  • A Linux or macOS terminal, or a bash environment on Windows
  • Optional: git, if you want a local copy of the repository

How do you get a local copy of bash-guide?

The README gives one install command: cloning the repository with git. This copies the guide to your computer so you can open the README locally and follow along in your terminal.

git clone https://github.com/Idnan/bash-guide

How is the guide organised?

The guide is split into sections. Basic Operations covers commands grouped by file operations, text operations, directory operations, SSH, system info and network operations, and process monitoring. Basic Shell Programming covers variables, arrays, string substitution, functions, conditionals, loops, regex and pipes. Tricks, Debugging and Multi-threading follow.

Each command has a short explanation, the syntax, and often a sample session showing the output. Read the entry, type the command in your own terminal on a test folder, and compare your output with the example.

  • Basic Operations: export, whatis, whereis, which, clear
  • File Operations: cat, cp, mv, rm, ls, find, gzip, gunzip, head, tail, touch and more
  • Text Operations: awk, cut, echo, grep, egrep, fgrep, sed, sort, tr, uniq, wc and more
  • Basic Shell Programming: variables through pipes
  • Tricks, Debugging and Multi-threading

How do you practise file commands safely?

Create a scratch folder first so you can experiment without touching important files. The guide shows touch creating a file, ls -la listing files including hidden ones, and cat combining text files. The README notes that rm on a directory gives an error, and that you need -r to remove a directory recursively. Add -f only when you want to skip confirmations.

  • ls -l shows size, owner, permissions and last-modified time in long format
  • ls -a includes hidden files
  • cp copies a file from a source to a destination
  • mv moves a file, and also renames it
  • rm on a directory needs -r; -f forces deletion without confirmation
  • gzip compresses files and gunzip reverses it; gzcat reads a gzipped file without unpacking it
mkdir scratch touch scratch/trick.md ls -la scratch rm -r scratch

How do you search and process text with awk?

The guide describes awk as useful for handling text files. It reads a file line by line and, by default, splits fields on whitespace. The -F option sets a different field separator. The example below prints the first field of /etc/passwd, using a colon as the separator, which gives the list of usernames.

  • Use -F to choose the field separator, here ':'
  • $1 means the first field, and print outputs it
awk -F':' '{ print $1 }' /etc/passwd

What basic scripting topics does the guide cover?

The second half of the guide introduces shell programming. Topics include variables, arrays, string substitution, functions, conditionals, loops, regex and pipes. The README is truncated in the source, so later sections may differ from what is described here.

Treat these entries as an introduction. The guide does not go deep into advanced patterns, so use it to learn the building blocks, then move on to a fuller reference when you need more.

  • Variables and arrays store values
  • Conditionals and loops control what runs and how often
  • Functions group reusable commands
  • Pipes pass one command's output into the next

What people use it for

  • Learning which command lists hidden files, copies folders or compresses logs, by looking up short examples
  • Refreshing file and text commands such as grep, sed or awk before a task
  • Picking up basic shell variables, loops and pipes before writing small scripts
  • Looking up what whatis, whereis and which report about a command on your system

Frequently asked questions

Is bash-guide free to use?

bash-guide is released under the MIT licence, which is a permissive open-source licence. You can read it and clone it with git at no cost, as described in the repository.

What do I need to install to use bash-guide?

The source lists no prerequisites and the guide is read online. The examples assume a Unix-like shell, so a Linux or macOS terminal is the practical requirement.

Can I use bash-guide on Windows?

The guide's examples assume a Unix-like shell, so Windows users need a bash environment to follow them. Without one, the commands will not run as written.

Does bash-guide cover advanced scripting?

No. The README covers basics and short tricks only. It is best for learning fundamentals, and you should look elsewhere for advanced scripting patterns.

Is bash-guide up to date?

Not necessarily. The last push to the repository was in August 2024, so check whether commands and examples still match your system.

How does bash-guide compare with other bash resources?

The source lists The Linux Command Line book, Bash Guide by Greg's Wiki, Learn Shell and explainshell as comparable projects. bash-guide is a short, example-driven quick reference, while the book is a longer course.

New agent skills, repos and AI tools — every week

The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.

Our verdict

bash-guide suits beginners who want quick, example-based reference for common terminal commands and a first look at shell scripting. Skip it if you need advanced patterns, Windows support without a bash environment, or up-to-date coverage, and consider the comparable projects listed above instead.

Install options & downloads