Skip to content
Happy Programming Guide
Start learning
Coding Tools

Command Line Basics for Beginners

The dozen terminal commands every programming tutorial assumes you already know — moving around, listing files, running programs, and what "is not recognized" actually means.

A close-up view of a MacBook Pro keyboard with code displayed on the screen

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.

Terminal
pwd            # macOS, Linux, PowerShell — print working directory
cd             # Windows Command Prompt, alone on a line

The 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?#

Terminal
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#

Terminal
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 were

Two habits that make this painless:

  • Tab completion. Type cd proj and 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#

Terminal
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 equivalent

Running your programs#

Terminal
cd my-project
python app.py            # or python3 on macOS/Linux
node script.js
git status
pip install requests

Note 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:

Terminal
where python        # Windows
which python        # macOS, Linux
python --version

Reading the prompt#

Terminal
(.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#

Terminal
Ctrl + C        # stop the running program
Ctrl + L        # clear the screen (or type: clear / cls)
exit            # close the terminal

Ctrl + 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#

Terminal
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 screen

The && 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#

Related lessonVS Code setup for beginners

Keep reading

Keep going — pick your next guide

The fastest way to improve is to read one guide, then build the thing it describes. Start with the basics, or jump straight to a project.

Ask a question or share what worked

Your email address will not be published. Required fields are marked *