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
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.
| Idea | In the building | In the terminal |
|---|---|---|
| Where am I? | Which room you are standing in | pwd |
| What is here? | Looking at the things in the room | ls |
| Go somewhere | Walking to another room | cd folder_name |
| Go back | Stepping out to the hallway | cd .. |
| Make a place | Building a new room | mkdir folder_name |
| Read something | Reading a note on the wall | cat file.txt |
The checklist
Try these in order. Each line shows the command, then what it does.
- pwd. Print the path of the current folder. It might show /Users/asha or /home/asha. This is your starting room.
- 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).
- mkdir lakebench. Make a new folder called lakebench inside the current folder.
- cd lakebench. Move into it. Run pwd again and you will see the path has grown by one folder.
- 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'.
- cat notes.txt. Print what is inside the file. You should see orders,100.
- 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.
| Symbol | Means | Example |
|---|---|---|
| . | The current folder | ls . |
| .. | The folder above | cd .. |
| ~ | Your home folder | cd ~ |
| / | 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.
$ 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.
$ 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.