Almost every programming guide you read will at some point say “run this in your terminal”. This page covers the dozen commands that assumption rests on.
You do not need to love the command line. You need enough of it to follow instructions without guessing.
Opening one#
| System | What to open |
|---|---|
| Windows | PowerShell (search for it in the Start menu) |
| macOS | Terminal (Cmd + Space, type “terminal”) |
| Linux | Terminal (usually Ctrl + Alt + T) |
| Any, inside VS Code | Ctrl and the ` key, or Terminal → New Terminal |
The VS Code one is the most convenient while you are coding, because it opens already inside your project folder.
Where am I?#
The single most useful command, because almost every “file not found” problem is really a “wrong folder” problem.
pwd # macOS, Linux, PowerShell — print working directory
cd # Windows Command Prompt, alone on a lineThe terminal always has a current folder, and it does not follow whichever file you have open in your editor. Commands run relative to it.
What is in here?#
ls # macOS, Linux, PowerShell
dir # Windows Command Prompt
ls -l # long form: sizes and dates
ls -a # include hidden files (names starting with a dot)Moving around#
cd projects # go into the projects folder
cd projects/my-app # go several levels at once
cd .. # up one level
cd ../.. # up two
cd ~ # your home folder
cd / # the root of the drive
cd - # back to where you just wereTwo habits that make this painless:
- Tab completion. Type
cd projand press Tab — the shell finishes the name. It also proves the folder exists. - Up arrow. Recalls previous commands. You will use this constantly.
Making and removing things#
mkdir my-project # make a folder
mkdir -p a/b/c # make nested folders (macOS/Linux)
touch notes.txt # create an empty file (macOS/Linux)
New-Item notes.txt # PowerShell equivalentRunning your programs#
cd my-project
python app.py # or python3 on macOS/Linux
node script.js
git status
pip install requestsNote the order: move into the folder first, then run the file by its name. Running python app.py from the wrong folder gives you “can’t open file”, which is the same wrong-folder problem again.
“is not recognized as an internal or external command”#
Windows says that; macOS and Linux say command not found. Both mean the same thing: the shell looked through its list of program locations and did not find that name.
It does not mean the program is broken or missing from your computer. Usual causes:
- It was never installed. Install it.
- It was installed but not added to PATH. Common with Python on Windows — see how to install Python.
- You installed it after opening this terminal. Close the terminal and open a new one; the environment is read at launch.
- Typo. Genuinely worth checking before anything else.
To check whether a command exists at all:
where python # Windows
which python # macOS, Linux
python --versionReading the prompt#
(.venv) ahmad@laptop:~/projects/my-app$That line is telling you four things: a Python virtual environment is active, who you are, which machine, and the current folder. When something behaves unexpectedly, read the prompt first — it often contains the answer. See Python virtual environments.
Stopping and clearing#
Ctrl + C # stop the running program
Ctrl + L # clear the screen (or type: clear / cls)
exit # close the terminalCtrl + C is the one to remember. It is how you escape an infinite loop or a program waiting on something that will never arrive.
Chaining commands#
mkdir demo && cd demo # run the second only if the first worked
python app.py > output.txt # send output to a file instead of the screenThe && form is worth knowing because setup instructions frequently use it.
Questions people ask#
PowerShell or Command Prompt on Windows?
PowerShell. It understands several Unix-style commands like ls and pwd, which means guides written for macOS mostly work. Command Prompt is the older, more limited one.
What is WSL?
Windows Subsystem for Linux — a real Linux environment inside Windows. Useful once you follow guides that assume Linux, and unnecessary while you are learning the basics.
What does sudo do?
Runs a command with administrator rights on macOS and Linux. Only use it when instructions specifically call for it, and read the command first — it can change system files.
Do I have to learn vim?
No. But if you ever end up in it by accident, press Esc then type :q! and Enter to leave without saving.
Why do guides show a $ or > at the start?
That represents the prompt. Do not type it — copy only what comes after it.
Where to go next#
- Git and GitHub explained — the commands you will use most
- VS Code setup for beginners
- How to install Python properly