Commands for interacting with the terminal
The terminal lets you control your computer by typing commands instead of clicking. These commands tend to have two or three parts:
$ [command] [options] [target]
| meaning | example | |
|---|---|---|
command |
What you want the computer to do | python, cd, ls |
options |
(Optional) Extra flags that change how it runs | -l, --version |
target |
What you want the command to act on | greeting.py, Lesson0 |
Some useful examples to get familiar with
Run a Python Script
$ python greeting.py
python - the command to run Python
greeting.py - the file you want to run
Change Folders
$ cd Lesson0
cd - the command to change directory
Lesson0 - the folder to move into
List Files in a Folder
$ ls
or for more details:
$ ls -l
ls - command to list files
-l - option for long format (shows more detail)
Show the Current Folder
$ pwd
pwd - command to “print” (to terminal) the path to the working directory; this shows you where you are in the file system
Quick Command Reference
| Action | Command |
|---|---|
| Run a Python file | python file.py |
| Move into a folder | cd folder-name |
| Move up one folder | cd .. |
| List files | ls |
| Show current folder path | pwd |
| Clear the screen | clear |
Beginner Tips
Use spaces between each part
✅ Correct:
$ cd ..
❌ Incorrect:
$ cd..
(Notice the lack of space between cd and ..)
File names are case sensitive
greeting.py is not the same as Greeting.py.
Press Tab to autocomplete
Start typing a file or folder name, then press Tab. The terminal will try to finish the name for you.
Example:
$ python gr[TAB]
becomes:
$ python greeting.py
← Back to where you were | → Start the course from the beginning
