Skip to content
LakeBench
ProblemsCommunityPricing
Sign inStart practicing

Infrastructure & Engineering Practices

Progress0/13
x

Terminal, Git and Docker basics

  • The terminal in 15 minutes14m
  • Git: working tree, index, commit12m
  • Git with a team: branch, push, pull request14m
  • Merge conflicts14m
  • PATH, pipes, and exit codes12m
  • Docker: run a container, then use Compose16m

Docker

  • Read a Dockerfile14m
  • Dockerfile bugs: USER root12m

Kubernetes and Terraform

  • Deployment vs CronJob14m
  • Terraform: the missing resource14m

CI/CD

  • CI/CD stages12m
  • CI order on main12m

Capstone

  • Capstone: ship checklist16m
Back to track
  1. Learn
  2. Infrastructure & Engineering Practices
  3. Terminal, Git and Docker basics
  4. The terminal in 15 minutes

Lesson 1 of 13 · Theory first, then run it

The terminal in 15 minutes

pythonbeginner14 min

Contents

  1. Goal
  2. Why this order
  3. The checklist
  4. Worked pass
  5. Common beginner questions
  6. What comes next
  7. Practice

Overview

A terminal always works from one current folder. pwd shows it, ls looks inside, cd moves, mkdir creates, cat reads. This tab only simulates folders.

On this page7 sections›
  1. 01Goal
  2. 02Why this order
  3. 03The checklist
  4. 04Worked pass
  5. 05Common beginner questions
  6. 06What comes next
  7. 07Practice

Goal

Most data engineering tools do not have a window with buttons. You run them by typing a command into a terminal. Airflow, dbt, Docker, Git and the AWS command line all work this way. If the terminal feels scary, every later lesson feels harder than it should.

This lesson takes about 15 minutes. By the end you can find out where you are, look inside a folder, move to another folder, make a new folder, and read a file. That is enough to follow almost every command in this course.

Nothing here can hurt your computer

Every command in this lesson only looks at things or makes a new empty folder. Open a terminal on your own computer and try each one as you read. On Mac, open the Terminal app. On Windows, install WSL or use Git Bash. On Linux, press Ctrl+Alt+T.

Why this order

A terminal always works from one place in your computer. That place is called the current folder (people also say the working directory). When you type a command like ls, the terminal runs it inside the current folder. So the first thing to learn is how to ask where you are, and the second is how to move.

Think of a big building with many rooms. You are always standing in one room. You can ask 'which room am I in?', look at what is in the room, walk to the next room, or go back to the room you came from. The terminal works the same way. That is why the order below is: find out where you are, look around, move, then create and read.

Six commands cover most of what you will do on this course.

IdeaIn the buildingIn the terminal
Where am I?Which room you are standing inpwd
What is here?Looking at the things in the roomls
Go somewhereWalking to another roomcd folder_name
Go backStepping out to the hallwaycd ..
Make a placeBuilding a new roommkdir folder_name
Read somethingReading a note on the wallcat file.txt

The checklist

Try these in order. Each line shows the command, then what it does.

  1. pwd. Print the path of the current folder. It might show /Users/asha or /home/asha. This is your starting room.
  2. ls. List what is in the current folder. Add -l to see sizes and dates, and -a to also see hidden files (files that start with a dot, like .env).
  3. mkdir lakebench. Make a new folder called lakebench inside the current folder.
  4. cd lakebench. Move into it. Run pwd again and you will see the path has grown by one folder.
  5. echo "orders,100" > notes.txt. Write the text orders,100 into a new file called notes.txt. The > means 'send the output into this file'.
  6. cat notes.txt. Print what is inside the file. You should see orders,100.
  7. cd .. . Move back up one folder. The two dots mean 'the folder above this one'.

A path is the full address of a file or folder. An absolute path starts from the very top, for example /home/asha/lakebench/notes.txt. A relative path starts from where you are now, for example lakebench/notes.txt. Both point to the same file when you stand in /home/asha. The shortcut ~ means your home folder, so ~/lakebench is the same as /home/asha/lakebench.

Four symbols you will see everywhere.

SymbolMeansExample
.The current folderls .
..The folder abovecd ..
~Your home foldercd ~
/The very top of the computer, or a separator between folders/home/asha/lakebench

Worked pass

Here is a real session. Lines that start with $ are what you type. The other lines are what the terminal prints back.

A short terminal session
$ pwd
/home/asha

$ ls
Desktop  Documents  Downloads

$ mkdir lakebench
$ cd lakebench
$ pwd
/home/asha/lakebench

$ echo "orders,100" > notes.txt
$ ls
notes.txt

$ cat notes.txt
orders,100

$ cd ..
$ pwd
/home/asha

Look at what happened to the path. Every cd changed the answer of pwd. mkdir and echo did not print anything. That is normal. Many commands print nothing when they work, and only speak up when something is wrong.

Now the other direction. If you type a folder name that does not exist, the terminal tells you plainly.

A mistake the terminal explains
$ cd reports
bash: cd: reports: No such file or directory

'No such file or directory' is the most common error you will see. It almost always means one of three things:

  • You are in a different folder than you think (run pwd).
  • You made a typo (check with ls).
  • The folder has not been created yet.

rm has no undo

rm deletes a file straight away. It does not go to a bin, and you cannot get it back. For now, avoid rm and rm -r. If you must delete something, run ls first to be sure of the name, then run the command slowly.

Two keys that save a lot of typing

Press the Tab key to finish a name for you: type cd lake and press Tab, and the terminal completes it to lakebench. Press the Up arrow to bring back the last command you typed, so you can fix a typo without typing everything again.

Common beginner questions

What is the difference between a terminal and a shell?

The terminal is the window. The shell is the program inside it that reads your commands and runs them. The most common shell is bash. On newer Macs it is zsh. For everything in this course they behave the same.

Why is my prompt different from the examples?

The prompt is the text before your cursor, like asha@laptop:~$ or just $. It is different on every computer. The $ in this course only marks 'type what comes after this'. Do not type the $ yourself.

Do I need to learn more commands?

Yes, slowly. cp copies a file, mv moves or renames a file, head shows the first lines of a file, and grep searches inside files. You can learn each one when a lesson needs it. The next lessons add Git and Docker.

What comes next

You can now move around and read files. Next you will learn how Git keeps a history of your project folder, and then how to use Git with a team. After that comes Docker, which runs programs in ready-made boxes. All three are typed in the terminal.

Practice

The exercise gives you a starting folder and a list of cd commands. Write final_dir() to work out which folder you end up in. This is the same thinking you do in a real terminal when you ask yourself 'where am I now?'.

Practicals · load into the editor

After you read the theory, run these in the pane on the right. They execute in this tab, no cluster.

Rate:
Was this useful?
Infrastructure & Engineering PracticesGit: working tree, index, commit