Your Python terminal setup starts here: open the terminal on Windows, Mac, or Linux, understand what a terminal actually is, and navigate your file system with a handful of basic commands. This is the one tool every developer touches daily, and it is far simpler than it looks from the outside.
“This is the Unix philosophy: Write programs that do one thing and do it well.”
Doug McIlroy, Bell Labs
Last Updated: July 2026 | Tested on: Python 3.14.6 | Difficulty: Beginner | Reading Time: 18 minutes
You have been clicking on icons your entire life. Double-click a folder to open it. Right-click to create a new file. Drag things to the trash. That graphical world (the windows, buttons, and mouse pointers) is called a GUI (Graphical User Interface). It is how most people interact with a computer, and it works fine for everyday tasks.
But there is another way to talk to your computer. Instead of clicking, you type commands. Instead of clicking through folders one window at a time, you type the folder name and hit Enter. This typed interface is called a terminal (you will also hear it called the command line, shell, or console). Those words mean slightly different things under the hood, but for now, treat them as the same thing.
Why should you care? Because every developer on the planet uses the terminal daily. Running Python scripts, installing libraries, managing project files, using Git: all of it happens through typed commands. The terminal is not some relic from the 1980s. For a lot of tasks it is simply the fastest way to get things done, and once it clicks, you will wonder why you ever bothered clicking through six nested folders.
Table of Contents
Your File System: The Map Before the Journey
Before you type a single command, you need a mental picture of how your computer organises files. Think of it like the floors of a tall building. The lobby is at the bottom, every floor sits above it, and each floor has rooms, and some rooms have cupboards inside them. To find anything, you start at the lobby and follow the directions up. Your file system works the same way.
Every computer stores files in a file system, a tree-shaped structure where folders contain files and other folders. At the very top sits the root directory. On Windows, that is usually C:\. On Mac and Linux, it is just /. Everything else (your documents, your programs, your cat photos) lives somewhere inside that tree.
Here is what a typical file system looks like. Imagine this is the laptop of a developer named Rahul, whose files we will use as the running example in this post:
The path is the address of any file or folder in this tree. To reach Rahul’s Python project, you would follow the branches from the root:
- Windows:
C:\Users\rahul\Documents\projects\my-python-app - Mac/Linux:
/Users/rahul/Documents/projects/my-python-app
Notice the difference? Windows uses backslashes (\), while Mac and Linux use forward slashes (/). This will matter later when you write Python code that works with files. For now, just remember: a path is a set of directions from the root to your destination, with each folder name separated by a slash.
Opening a Terminal
Every operating system has a terminal built in, so this part of your Python terminal setup needs no downloads at all. Here is how to find yours.
Windows
You have three options, from oldest to newest:
- Command Prompt (cmd): the classic. Press
Win + R, typecmd, hit Enter. It works, but it is showing its age. - PowerShell: a more powerful replacement. Press
Win + X, then select “Windows PowerShell.” Most modern Windows installations default to this. - Windows Terminal: the best option. It is a tabbed, customisable app that can run cmd, PowerShell, or even Linux (via WSL, the Windows Subsystem for Linux) in separate tabs. Download it free from the Microsoft Store if you do not already have it. On Windows 11, it is pre-installed.
Recommendation: Use Windows Terminal with PowerShell. It gives you the cleanest Python terminal setup on Windows, and the commands in this tutorial will work as-is.
Mac
Open Terminal.app. The fastest way: press Cmd + Space to open Spotlight, type “Terminal,” and hit Enter. It lives in /Applications/Utilities/ if you want to find it manually.
Mac’s terminal runs a shell called zsh by default (since macOS Catalina). Older Macs used bash. For everything in this tutorial, the difference does not matter.
Linux
If you are running Linux, you probably already know where the terminal is. But just in case: press Ctrl + Alt + T on most distributions (Ubuntu, Debian, Fedora). Or search for “Terminal” in your application menu. Linux typically uses bash as the default shell.
Where Am I? pwd and cd
When you open a terminal for the first time, you are dropped into a specific folder. But which one? There is no visual cue like a file manager. Just a blinking cursor. It is like stepping out of a lift in a huge shopping mall: before you walk anywhere, you look for the “You are here” dot on the floor map. In the terminal, your first instinct should be the same: find out where I am.
📄 Terminal: find your current location
pwd
▶ Output (Mac/Linux)
/Users/rahul
▶ Output (Windows PowerShell)
C:\Users\rahul
pwd stands for print working directory. It tells you exactly where you are in the file system tree. On Windows Command Prompt, the equivalent is cd by itself (with no arguments). On PowerShell, pwd works too.
Most terminals start you in your home directory, which is your personal folder (like /Users/rahul on Mac or C:\Users\rahul on Windows). Think of it as your home base. No matter how far you wander, you can always get back here.
Now, how do you move? That is where cd comes in, short for change directory.
📄 Terminal: navigate into a folder
cd Documents
That moves you one level deeper, from /Users/rahul into /Users/rahul/Documents. Run pwd again to confirm.
📄 Terminal: go back up one level
cd ..
Two dots (..) mean “the parent folder,” one level up in the tree. If you were in /Users/rahul/Documents, this takes you back to /Users/rahul.
You can also jump directly to any folder by typing the full path:
📄 Terminal: jump to a specific path
# Mac/Linux cd /Users/rahul/Documents/projects # Windows cd C:\Users\rahul\Documents\projects
What happened here: Instead of moving one folder at a time, you gave the terminal the complete address. This is called an absolute path because it starts from the root. The previous examples (cd Documents, cd ..) are relative paths because they are relative to your current location.
One more shortcut that will save you time: typing cd ~ (tilde) takes you straight back to your home directory, no matter where you are. It works on Mac, Linux, and PowerShell. Only the old Windows Command Prompt does not understand it.
Looking Around: ls and dir
Now that you can move between folders, you need to see what is inside them. Think of walking into a room with the lights off: you flip the switch to see what is actually in there. In a GUI, opening a folder window is that light switch. In the terminal, you ask for a listing instead.
📄 Terminal: list files in the current folder
# Mac/Linux/PowerShell ls # Windows Command Prompt dir
▶ Output (example from Rahul’s projects folder)
my-python-app portfolio-site notes.txt
ls stands for list. It shows every file and folder in your current directory. On Mac/Linux, folders and files are displayed differently (often color-coded). On Windows Command Prompt, dir gives you a detailed listing with file sizes and dates.
Want more detail? Add a flag:
📄 Terminal: detailed listing with hidden files
# Mac/Linux: long format with hidden files ls -la # PowerShell: include hidden items Get-ChildItem -Force
▶ Output (Mac/Linux, simplified)
drwxr-xr-x 4 rahul staff 128 Mar 20 14:30 my-python-app drwxr-xr-x 3 rahul staff 96 Mar 18 09:15 portfolio-site -rw-r--r-- 1 rahul staff 245 Mar 22 11:00 notes.txt -rw-r--r-- 1 rahul staff 52 Mar 15 08:00 .gitconfig
The -la flags mean “long format” and “all files” (including hidden ones that start with a dot). The d at the beginning of a line means it is a directory (folder). A - means it is a regular file. Do not worry about memorising the permission letters right now. That is a Linux administration topic, not a Python one.
Creating Folders and Files
Developers create folders and files from the terminal all the time. It is like labelling a new box before you put anything in it: one quick action, and there is now a named place for your stuff. And it is faster than right-clicking and navigating menus.
📄 Terminal: create a new folder
mkdir my-first-project
mkdir stands for make directory. This creates a new empty folder called my-first-project inside your current location. The command works the same on Windows, Mac, and Linux.
📄 Terminal: create nested folders in one shot
# Mac/Linux mkdir -p projects/python-app/data # Windows PowerShell (creates the whole path by default) mkdir projects/python-app/data
On Mac/Linux, the -p flag tells mkdir to create every folder in the path, even if the parent folders do not exist yet. Without it, you would get an error if projects did not already exist. PowerShell is friendlier here: its mkdir creates the whole nested path by default, no flag needed.
Creating files is a little different depending on your OS:
📄 Terminal: create an empty file
# Mac/Linux touch hello.py # Windows PowerShell New-Item hello.py -ItemType File
touch creates an empty file (or updates its timestamp if it already exists). On Windows, New-Item does the same job. After running this, you will have a file called hello.py in your current folder. Ready for you to write Python code in it.
Let us verify that everything worked:
📄 Terminal: verify the folder and file were created
cd my-first-project ls
▶ Output
(empty: the folder exists but has nothing in it yet)
An empty listing means the folder was created successfully but it is empty. If you ran touch hello.py inside this folder, running ls again would show hello.py.
Putting It All Together: A Python Terminal Setup Workflow
Here is a realistic sequence of commands that sets up a Python project from scratch. This is where the Python terminal setup pays off, because you will repeat this exact routine every time you start something new.
📄 Terminal: setting up a new Python project
# Start from your home directory cd ~ # Create a projects folder (skip if it already exists) mkdir -p Documents/projects # Navigate into it cd Documents/projects # Create your project folder mkdir expense-tracker # Go inside cd expense-tracker # Create the initial files touch main.py touch README.md # Verify ls
▶ Output
main.py README.md
What happened here: You navigated to your home directory, created a nested folder structure, moved into it, created two files, and confirmed they exist. Eight commands, maybe 20 seconds of typing. Doing the same thing with a mouse and right-click menus would take longer and feel clumsier once you get used to this.
Check where you ended up:
📄 Terminal: confirm your location
pwd
▶ Output
/Users/rahul/Documents/projects/expense-tracker
That is exactly where you want to be when you start writing Python code in the next tutorial, where you install Python and write your first program.
What Is PATH? Why python Works as a Command
Here is something that confuses a lot of beginners. When you type python in the terminal, how does your computer know what to run? You did not type the full location of the Python program. You just typed a word. So how does it find Python?
The answer is a special setting called PATH. It is a list of folders where your operating system looks for programs when you type a command. Think of it like the contacts app on your phone. You type a friend’s name, say “Aviraj,” and your phone already knows the number behind it. PATH does the same trick for commands: you type python, and the operating system walks through each folder in PATH, one by one, until it finds a program called python.
📄 Terminal: see your PATH
# Mac/Linux echo $PATH # Windows PowerShell $env:PATH
▶ Output (simplified example)
/usr/local/bin:/usr/bin:/bin:/Users/rahul/.local/bin
That colon-separated list (semicolon-separated on Windows) is all the folders your OS searches. When you install Python in the next tutorial, the installer adds Python’s folder to this list. If it does not, or if something goes wrong along the way, you will hit the dreaded “python is not recognized as an internal or external command” error. Now you know why: the folder containing python.exe is not in your PATH.
You do not need to memorise how PATH works right now, but it is the piece of any Python terminal setup that breaks most often. Just remember this: when a command “is not found,” the problem is almost always PATH. That one sentence will save you hours of confusion when installing tools.
The Catch: Spaces in Folder Names
This one trips up every single beginner. Honestly, it still catches experienced developers who type too fast. Say you have a folder called My Projects (with a space in the middle) and you try to walk into it.
📄 Terminal: the broken version
cd My Projects
▶ Output
bash: cd: too many arguments
The terminal sees My and Projects as two separate words. It tried to cd into My, then had no idea what to do with the leftover Projects. The space is the problem: to the shell, a space means “here is where one word ends and the next begins.” The fix is to wrap the whole name in quotes.
📄 Terminal: the fixed version
cd "My Projects"
Or use a backslash to “escape” the space:
📄 Terminal: escaping the space
cd My\ Projects
Pro tip: Avoid spaces in project folder names entirely. Use hyphens (my-project) or underscores (my_project) instead. Every experienced developer does this, and now you know why.
Common Mistakes
Mistake 1: Forgetting where you are
You create a file, but it ends up in the wrong folder because you forgot to check your location first. Get into the habit of running pwd before creating files or running scripts. It takes one second and saves minutes of confusion.
Mistake 2: Using the wrong slash
Windows uses backslashes (C:\Users\rahul), Mac/Linux use forward slashes (/Users/rahul). Typing the wrong one produces errors. The good news: PowerShell actually accepts both. The bad news: the old Command Prompt does not.
Mistake 3: Typing commands inside a text editor instead of the terminal
This sounds silly, but it happens. ls, cd, mkdir, these are terminal commands, not Python code. If you type ls inside a Python file and try to run it, Python will have no idea what you mean. Terminal commands go in the terminal. Python code goes in .py files.
Conclusion
The terminal is just a text-based way to talk to your computer, and a Python terminal setup is nothing more exotic than knowing how to open it and where you are inside it. It is not scary, and it is not complicated. Give it a week of daily use and it turns into the fastest way you have to navigate files, create projects, and run programs.
You learned five core commands today:
pwd: where am I?cd: move to a different folderls/dir: list what is heremkdir: create a foldertouch/New-Item: create a file
Five commands, and your Python terminal setup is complete. That is all you need to set up any project. In the Python installation guide, you will install Python on your machine, open Visual Studio Code (VS Code), and run your first real Python script. The terminal skills from this post are exactly what you will use to do it. And if you want to see the full learning path from beginner to AI/ML, visit the Python + AI/ML tutorial series home for every post in order.
Practice Exercises
- Exercise 1: Open a terminal and run
pwd. Write down your home directory path. Then runcd ..twice, runpwdafter each one, and watch yourself climb the file system tree. - Exercise 2: Create a
python-practicedirectory and ahello.pyfile inside it using only terminal commands, then confirm both exist withls(ordir). - Exercise 3: Print your PATH with
echo $PATH(Mac/Linux) or$env:PATH(PowerShell) and count how many folders are in the list. You now know every place your OS looks when you type a command.
Frequently Asked Questions
What is a terminal in simple words?
A terminal is a text-based interface to your computer. Instead of clicking icons and menus, you type commands to navigate folders, create files, run programs, and manage your system. Every operating system ships with one: Terminal on Mac, PowerShell on Windows, and various terminal emulators on Linux.
Is the terminal the same as the command prompt?
Not exactly, but they are closely related. The terminal is the window application where you type commands. The shell (like bash, zsh, or PowerShell) is the program that interprets those commands. The command prompt specifically refers to the older Windows shell (cmd.exe). In everyday conversation, most developers use these terms interchangeably.
What is the difference between a file and a folder?
A file contains data, such as text, code, an image, or a spreadsheet. A folder (also called a directory) is a container that holds files and other folders. Think of folders as filing cabinet drawers and files as the documents inside them. Your entire computer is organised this way, from the root directory all the way down.
What is PATH and why does it matter for Python?
PATH is an environment variable, a list of folders where your operating system looks for programs. When you type python in the terminal, your OS checks every folder in PATH until it finds the Python executable. If Python’s installation folder is not in PATH, you get a “command not found” error. Most Python installers add themselves to PATH automatically, but if something goes wrong during installation, PATH is the first thing to check.
Do I need to learn terminal commands to learn Python?
You do not strictly need to, but you absolutely should. Running Python scripts, installing packages with pip, using Git for version control, and deploying applications all happen through the terminal. Skipping it now just delays the learning. A basic Python terminal setup built on the five commands in this tutorial (pwd, cd, ls, mkdir, touch) covers 90% of what you will need for the first half of this series.
What is the difference between an absolute path and a relative path?
An absolute path starts from the root directory and gives the complete address of a file or folder, like /Users/rahul/Documents/projects/main.py. A relative path starts from your current location, like projects/main.py (if you are already in the Documents folder). Absolute paths always work regardless of where you are. Relative paths are shorter but depend on your current directory.
Interview Questions on Terminal Basics
How interviewers actually probe this topic: real scenarios, with answers you can say out loud.
Q: You install a new command-line tool, but typing its name gives “command not found.” A colleague suggests closing and reopening the terminal, and that fixes it. Why did that work?
The shell reads PATH once, when the terminal session starts. The installer updated PATH on the system, but your already-open terminal was still holding the old copy of it. Opening a fresh terminal loads the updated PATH, so the shell can now find the tool’s folder. This is why “restart your terminal after installing” is standard advice.
Q: What is the difference between cd .. and cd ~?
cd .. is a relative move: it takes you one level up, to the parent of your current folder, wherever you happen to be. cd ~ is a jump to a fixed destination: your home directory (like /Users/rahul), no matter how deep in the tree you are. Run cd .. repeatedly and you eventually reach the root. Run cd ~ once and you are home.
Q: A beginner named Anvi runs touch notes.txt, then opens her Documents folder in the file manager and cannot find the file anywhere. What most likely happened?
The file was created, just not in Documents. touch creates the file in the current working directory of the terminal, which may have been her home folder or somewhere else entirely. The first debugging step is pwd to see where the terminal actually was, then ls to confirm notes.txt is sitting there. This is exactly why checking your location before creating files is a core habit.
Q: What does mkdir -p do, and when would plain mkdir fail?
On Mac/Linux, mkdir -p a/b/c creates the entire chain of folders, making any missing parents along the way. Plain mkdir a/b/c fails with “No such file or directory” if a or a/b does not already exist, because it only creates the last folder in the path. PowerShell’s mkdir creates the full nested path by default, so no flag is needed there.
Q: Why do developers avoid spaces in project folder names, and how do you deal with a folder that already has one?
The shell treats a space as the separator between arguments, so cd My Projects looks like two separate words instead of one folder name. To work with an existing folder, wrap the name in quotes (cd "My Projects") or escape the space with a backslash (cd My\ Projects). For new projects, sidestep the problem entirely with hyphens or underscores, like my-projects.
Q: Your teammate Anvay, who works on Windows, sends you the path C:\Users\anvay\project\data.csv and your Mac terminal cannot open it. What two differences explain this?
First, the separators differ: Windows paths use backslashes while Mac/Linux use forward slashes. Second, the roots differ: Windows starts at a drive letter like C:\, while Mac/Linux start at /, so that absolute path simply does not exist on your machine. An absolute path is only valid on the computer it describes. Within a shared project, use relative paths from the project folder so they work for everyone.
More in this series:
- Python: What is Programming? Code as Recipes Your Computer Follows
- Python Variables: Naming, Assignment, and the Memory Model
- Python: Data Types (int, float, str, bool, complex, bytes, bytearray, None)
Previous in Series: Python: What is Programming? Code as Recipes Your Computer Follows
Next in Series: Python: Install Python, VS Code & Write Your First Program (Hello World)
Related Topics You Might Like:
- Python: Why Learn Python in 2026, Ecosystem, Jobs, Use Cases
- Python: Variables, Naming, Assignment, and Memory Model
- Python: File Handling, Reading and Writing Text Files
This post is part of the Python + AI/ML Cookbook series on TechnoScripts.com
Go deeper: the official Python documentation covers every edge case of this topic.
Related Posts
Previous: Python: Why Learn Python in 2026. Ecosystem, Jobs, Use Cases
Next: Python: Install Python, VS Code & Write Your First Program (Hello World)
Series Home: Python + AI/ML Tutorial Series

No comment