Module 3 · Beginner · Files, folders and the terminal

What is the terminal (command line)?

What the terminal is: terminal vs shell vs command line, how to open it on Windows, Mac and Linux, how a command is built, and why programmers use it.

By theprogrammers team · · 11 min read

In tutorials you'll see people type into a black window: cd project, python app.py, git push. Text scrolls past, and things happen. For many beginners this is the scariest part of programming, because it looks like hacking in a film. It isn't. The terminal is just another way to use your computer: instead of clicking icons, you type short commands. This lesson explains what the terminal (also called the command line) is, how to open it, how to read a command, and why every programmer uses it.

You can't break your computer by opening a terminal and typing dir or ls. Most commands only look at things. The few that change or delete things are covered carefully in the next lesson. By the end of this one, you'll have run your first commands.

What you need first: files, folders and file paths.

Key terms

  • Terminal: the window where you type commands and see their output.
  • Shell: the program inside the terminal that reads your commands and runs them. Common shells are PowerShell, Command Prompt, bash and zsh.
  • Command line (CLI): the general idea of controlling a computer by typing commands. CLI means command-line interface.
  • GUI: graphical user interface, controlling a computer with windows, icons and clicks.
  • Prompt: the text the shell shows when it's waiting for you, often ending in > or $.
  • Command: an instruction you type, such as cd Documents.

Terminal, shell and command line

People use these words almost interchangeably, but they're slightly different things:

WordWhat it isComparison
TerminalThe windowA phone
ShellThe program that understands your commandsThe person you're talking to
Command lineThe way of working: typing commandsMaking a phone call instead of sending a letter

The difference between a terminal and a shell

The terminal and the shell are two separate programs that work as a pair:

  • The terminal handles the screen and the keyboard. It draws the text, shows colours and fonts, gives you tabs and scrolling, and passes your key presses on. It doesn't understand a single command.
  • The shell handles the meaning. It reads the line you typed, works out the command, options and arguments, finds the program, runs it, and sends the output back for the terminal to show.

Here's what happens when you type ls and press Enter:

You press keys -> Terminal -> sends "ls" -> Shell -> runs the ls program
You see output <- Terminal <- draws the text <- Shell <- gets the output

Because they're separate, you can mix and match them. Windows Terminal can open a tab running PowerShell, another running Command Prompt, and a third running bash inside WSL: one terminal, three shells. And the same bash shell can run inside the Ubuntu Terminal app, VS Code's built-in terminal, or a remote server window.

TerminalShell
JobShows text, takes key pressesUnderstands and runs commands
ExamplesWindows Terminal, macOS Terminal, iTerm2, GNOME Terminal, VS Code's terminal panelPowerShell, Command Prompt (cmd), bash, zsh, fish
What you change in itFont, colours, tabs, window sizeCommands, variables, scripts, the prompt, aliases
Works without the other?It can open, but needs a shell to do anythingYes, it can run a script file with no window at all

A few features belong to the shell even though you use them in the terminal window: command history (the up arrow), Tab completion, variables like $HOME, and the prompt's text. Copy and paste, font size and scrollback belong to the terminal.

The name "terminal" comes from history. In the 1970s, a terminal was a physical device: a keyboard and a screen (or printer) connected by cable to a big shared computer. Today's terminal apps imitate those devices in software, which is why their full name is terminal emulator. The shell, meanwhile, was always software: it's the outer layer, or "shell", around the operating system's kernel, which is where its name comes from. See what is an operating system? for the kernel.

To find out which shell you're in:

ShellCommandShows
bash or zsh (Mac, Linux)echo $SHELLYour default shell, such as /bin/zsh
PowerShell$PSVersionTable.PSVersionThe PowerShell version
Command Promptecho %COMSPEC%C:\Windows\system32\cmd.exe

The shell you get depends on your system:

SystemDefault terminal appDefault shell
Windows 10 and 11Windows Terminal or PowerShellPowerShell (Command Prompt is older)
macOSTerminalzsh
Linux (Ubuntu and others)Terminalbash

The commands in this course work in PowerShell on Windows, and in zsh or bash on Mac and Linux, unless we say otherwise. Command Prompt (cmd) is older and uses some different commands, so on Windows, use PowerShell.

How to open the terminal

  • Windows: press the Windows key, type terminal or powershell, press Enter.
  • macOS: press Cmd+Space, type terminal, press Enter.
  • Linux (Ubuntu): press Ctrl+Alt+T.
  • VS Code (any system): press `Ctrl+ `` (the backtick key, below Esc), or use the Terminal menu, New Terminal. It opens in your project folder, which is very handy.

Reading the prompt

When the terminal opens, you'll see a prompt. On Windows PowerShell it looks something like:

PS C:\Users\Ahana>

On a Mac:

ahana@Ahanas-MacBook ~ %

On Linux:

ahana@laptop:~$

The important part is the folder shown in the prompt: C:\Users\Ahana or ~ (your home folder). That's the current working directory: where you are, and where commands will act unless you say otherwise. The >, % or $ at the end means "ready for your command". You don't type the prompt itself; you type after it.

Your first commands

Try these. Type each one and press Enter.

Where am I?

pwd

pwd means "print working directory". It shows the full path of the folder you're in. It works in PowerShell too.

What's in this folder?

ls

ls ("list") shows the files and folders here. In PowerShell ls also works; in the old Command Prompt it's dir.

Move into a folder:

cd Documents

cd means "change directory". Run pwd again and you'll see you've moved. cd .. goes back up one level.

Say something:

echo Hello from the terminal
Hello from the terminal

echo prints whatever you give it. That's the terminal's version of Python's print.

The parts of a command

Most commands have the same shape:

command  options   arguments
  ls       -l       Documents
PartMeaningExample
CommandThe program to runls, python, git
Options (flags)Change how it behaves; usually start with - or ---l for a detailed list, --version
ArgumentsWhat to act onA file or folder name

So ls -l Documents means "list, in long (detailed) form, the contents of Documents". And python app.py means "run the python program, with the file app.py as its argument".

Spaces separate the parts, which is why file names with spaces need quotes: cd "My Projects". Otherwise the shell thinks My and Projects are two separate arguments.

Many commands show their own help:

python --version
git --help

--version and --help work with most programs. On Mac and Linux, man ls shows the full manual for ls (press q to leave it).

Why programmers use the terminal

If clicking works, why type? Because for programming work, the terminal is faster and does things a GUI can't:

  • Many tools only have a command line. Git, pip, npm, Docker and most server tools are used by typing commands.
  • Servers have no screen. When you connect to a cloud server, the terminal is all you get.
  • Commands can be repeated and saved. You can rerun a command with the up-arrow key, or save several in a script, and get exactly the same result every time. Clicking can't be scripted as easily.
  • It's faster for many tasks. Renaming 200 files or searching every file in a project for a word takes one line.
  • Instructions are easy to share. "Run pip install pandas" is clearer than "click here, then there".

You don't have to give up the GUI. Most programmers use both: VS Code and a browser for writing and reading, the terminal for running, installing and Git.

Shortcuts that make life easier

KeyDoes
TabCompletes a file or folder name. Type cd Doc and press Tab
Up arrowShows the previous command, to run it again
Ctrl+CStops the running command, such as an infinite loop
Ctrl+L or clearClears the screen (cls in Command Prompt)
Ctrl+RSearches your past commands (bash and zsh)

Tab is the one to use constantly. It saves typing and prevents spelling mistakes in long file names.

Ctrl+C in the terminal doesn't copy. It stops the running program. To copy text, select it and use Ctrl+Shift+C on Linux, Cmd+C on a Mac, or right-click in Windows Terminal.

Running Python from the terminal

This is the command you'll use most at first:

python app.py

It runs the file app.py from the current folder. On Mac and Linux it's often python3 app.py. If you get "can't open file" or "No such file or directory", you're in the wrong folder: use cd to get to the file's folder first, then run it. How to run Python code has the details.

Typing just python (with no file) starts the Python REPL, an interactive prompt (>>>) where you type Python one line at a time. Type exit() to leave it and get back to the shell prompt.

Common mistakes

  • Typing the prompt. Don't type PS C:\Users\Ahana> or $; type only the command after it.
  • Being in the wrong folder. Check with pwd before running anything.
  • Forgetting quotes around names with spaces.
  • Pasting commands you don't understand from random websites, especially ones that delete files, use sudo, or download and run scripts. Read first.
  • Panicking at red text. Error messages are information. Read them; they usually say what's wrong.

Practice

  1. Open a terminal, then find out which folder you're in and list its contents.
Show the answer

Run pwd to see the folder, then ls (or dir in Command Prompt) to list what's in it. Your output will show your own folder and files.

  1. In git commit -m "Add login page", which part is the command, which is the option, and which are arguments?
Show the answer

git is the command. commit is an argument to git (a sub-command), -m is an option meaning "message", and "Add login page" is the message argument for that option. The quotes keep the three words together as one argument.

  1. You run cd My Projects and get an error. Why, and how do you fix it?
Show the answer

The space splits the name into two arguments, My and Projects. Put the name in quotes: cd "My Projects". Better still, use names without spaces, like my-projects.

  1. A Python program is stuck printing the same line for ever. How do you stop it?
Show the answer

Press Ctrl+C in the terminal. It sends an interrupt that stops the running program.

  1. Run python --version in your terminal. What does it show? If it shows an error, what might that mean?
Show the answer

It shows your Python version, such as Python 3.13.5. An error like "not recognized" or "command not found" means Python isn't installed or isn't on your PATH; see how to install Python and environment variables and PATH.

  1. In VS Code's terminal panel you can choose between "PowerShell", "Command Prompt" and "Git Bash" from a drop-down. Are you choosing a terminal or a shell?
Show the answer

A shell. The terminal stays the same (VS Code's panel); the drop-down picks which shell runs inside it.

Key takeaways

  • The terminal is a text window where you control the computer by typing commands.
  • The shell (PowerShell, zsh, bash) reads and runs your commands; the prompt shows your current folder.
  • Commands have the shape: command, options, arguments.
  • pwd, ls, cd and echo are the first four to learn; Tab completes names and Ctrl+C stops a program.
  • Programmers use the terminal because many tools and all servers work through it.

Frequently asked questions

Is the terminal the same as Command Prompt?

Command Prompt (cmd) is one old Windows shell. The terminal is the window; on Windows it can run PowerShell, Command Prompt or a Linux shell through WSL. For programming on Windows, use PowerShell or WSL.

What is the difference between a terminal and a shell?

The terminal is the program that shows text and takes your typing; the shell is the program that understands and runs your commands. Windows Terminal, macOS Terminal and VS Code's terminal are terminals; PowerShell, bash and zsh are shells. One terminal can run different shells in different tabs.

Can typing in the terminal damage my computer?

Commands that only look at things, like pwd, ls and cd, can't damage anything. Commands that delete or change files (such as rm or del), or that run with administrator rights (sudo), can. Read any command before running it, especially ones copied from the internet.

Do I need to learn the terminal to code?

Yes, the basics. You'll need it to run programs, install packages with pip, use Git and work on servers. About 15 to 20 commands cover most daily work, and the next lesson teaches them.

What to learn next

  1. Learn the 20 commands you'll use most in terminal commands every beginner needs.
  2. Revise folders and paths in files, folders and file paths.
  3. Run your first script with how to run Python code.