terminal commands
No account is required. Learn the material, try the examples, and mark it complete locally when you are ready to move on.
Navigating the Terminal
Before we run our Python script, let's learn a few basic terminal commands.
You don't need to become a Linux expert.
We only want to learn enough to move around our project files and run our programs.
Imagine your computer's files as a set of folders:
home/
└── student/
├── projects/
│ ├── app.py
│ └── notes.txt
└── downloads/The terminal lets us move through this structure.
Where am I?
Use:
pwdpwd means Print Working Directory.
It tells you which folder you are currently inside.
For example:
/home/student/projectsThink of it as asking:
"Where am I right now?"
What is inside this folder?
Use:
lsls shows the files and folders in your current location.
For example:
app.py
notes.txt
projectsThink of it as:
"What is around me?"
Move into a folder
Use:
cd foldercd means Change Directory.
For example, if you have:
projects/
app.py
python/you can move into the python folder:
cd pythonYour current location has now changed.
You can check it with:
pwdAnd see what's inside with:
lsMove back one folder
Use:
cd ..The .. means:
"The folder above my current folder."
For example:
projects/
└── python/
└── app.pyIf you are inside python:
cd ..you will move back to:
projects/You can think of it like going up one level in the folder structure.
Move into a folder and back out
Let's practice.
Start by looking at where you are:
pwdSee what's there:
lsFind a folder and move into it:
cd folderLook around:
lsThen go back:
cd ..Check your location again:
pwdYou have now navigated through the filesystem using the terminal.
The four commands to remember
For now, these four commands are enough:
| Command | What it does |
|---|---|
pwd | Shows where you are |
ls | Shows what's here |
cd folder | Moves into a folder |
cd .. | Moves up one folder |
A useful mental model is:
pwd → Where am I?
ls → What's here?
cd → Move somewhere
.. → Go up one levelFinding app.py
Let's connect this back to our Python program.
Suppose your project looks like this:
projects/
└── my-first-program/
└── app.pyYou can navigate to your project with:
cd projectsThen:
cd my-first-programCheck what's inside:
lsYou should see:
app.pyNow you can run your program:
python app.pyNotice the workflow:
Navigate to project
↓
Find app.py
↓
Run app.py
↓
See the outputThis is why we're learning the terminal.
We're not memorizing random commands.
We're learning how developers move around their projects and run their code.
One More Useful Command
You can clear the terminal with:
clearThis doesn't delete anything.
It simply clears the text currently visible in your terminal.
Terminal Practice
Try completing this sequence:
pwd
lsFind a folder you can enter, then:
cd folder
pwd
lsThen go back:
cd ..
pwdFinally, navigate back to your Python project and run:
python app.pyIf you can do this without getting lost, you've learned enough terminal navigation for now.
We'll learn more commands when we actually need them.
Lesson resources
Supporting code and files from this part of the curriculum.
Finished this lesson?
Completion is saved in this browser without creating an account.