TetSharing
Git & CLI tutorial · 12 chapters
  1. Terminal basics
  2. Working with files
  3. Pipes and redirection
  4. What Git is
  5. Staging and commits
  6. Viewing history
  7. Comparing changes
  8. Branches
  9. Merging
  10. Merge conflicts
  11. Undoing changes
  12. Remotes, push and pull

Final Git & CLI quiz
Cheat sheet: git commands
Cheat sheet: linux shell commands

Chapter 1 of 12 · By Ethan Cole · Updated November 21, 2026

Command Line for Beginners: pwd, ls, cd and mkdir

A terminal is a window where you type commands instead of clicking. The program that reads those commands is the shell; on Linux and in Git Bash it is usually bash, and on macOS it is zsh, which accepts the same basic commands. Developers use the terminal because it is fast, scriptable and the same on every server.

Reading a transcript

In this track, examples are transcripts. A line starting with $ is something you type (do not type the $ itself, it stands for the prompt). The lines after it are what the computer printed. Our test suite runs every transcript in a fresh empty folder, so the output is real. Your own folder names and prompt will look different.

Where am I? pwd

Everything in the shell happens inside a current directory (directory is the traditional word for folder). pwd, "print working directory", shows it. In our transcripts the test folder is shown as ~/demo; ~ is shorthand for your home directory.

What is here? ls

ls lists the contents of the current directory. ls -l adds details such as size and date, and ls -a also shows hidden entries whose names start with a dot, like .git. Options like -l are called flags, and most commands accept several.

Moving: cd

cd projects changes into the projects folder. Two special names help you move around:

  • .. is the parent directory, so cd .. goes up one level.
  • . is the current directory, used in commands like ./script.sh.

cd with no argument returns to your home directory. Paths starting with / are absolute (from the top of the file system); others are relative to where you are.

Creating folders: mkdir

mkdir notes creates a directory. mkdir -p a/b/c creates the whole chain at once and does not complain if parts already exist.

Terminal · bash + git · copy and run locally
# Each example starts in an empty folder, shown as ~/demo
pwd
mkdir -p projects/website
ls
cd projects
pwd
ls
cd website
pwd
cd ..
cd ..
pwd

Transcript (verified by our test suite in a fresh temp folder)

$ pwd
~/demo
$ mkdir -p projects/website
$ ls
projects
$ cd projects
$ pwd
~/demo/projects
$ ls
website
$ cd website
$ pwd
~/demo/projects/website
$ cd ..
$ cd ..
$ pwd
~/demo

Follow the transcript line by line and watch pwd change as cd moves around. The ls after cd .. shows the folder we created.

Tab completion and history

Two habits save a lot of typing. Press Tab after typing the start of a file or folder name and the shell completes it. Press the Up arrow to bring back earlier commands. Both also prevent typos.

Common mistakes

  • Spaces in names: cd my folder tries to enter my. Quote it: cd "my folder".
  • Upper versus lower case: on Linux, Notes and notes are different folders.
  • Typing the $ from a transcript; it is only the prompt.

Summary

  • pwd shows where you are, ls what is there.
  • cd name, cd .. and cd move you; mkdir -p creates folders.
  • $ marks commands in a transcript; the rest is output.

Quiz: Terminal basics

1. Which command shows the directory you are currently in?

pwd prints the working directory.

2. What does cd .. do?

.. is the parent directory.

3. How do you list hidden files such as .git as well?

-a shows all entries, including names that start with a dot.

Official docs

Written under the pen name Ethan Cole with AI-assisted drafting. Every code example on this page is executed by our test suite before publishing. Found a mistake? Tell us.