Introduction to the Command Line

Reviewed & published by Brayan K

The command line is a text-based way to control your computer by typing instructions into a terminal, where a shell reads each command and carries it out immediately.

Part of the free Command Line course at LearnCodingFast — hands-on lessons with worked examples and the output they print, plus practice exercises and a quick quiz.

By the end of this lesson you'll know what the command line, shell, and terminal actually are, you'll be able to read a command prompt, and you'll have run your first four real commands — echo, pwd, whoami, and date.

What You'll Learn

💡 Real-World Analogy

Think of the graphical interface (the windows, icons, and buttons you click) as ordering from a menu with pictures — quick and friendly, but you can only pick what's on the menu. The command line is like talking directly to the chef: you can ask for anything, customise every detail, and repeat the exact same order a thousand times without lifting a finger. It looks bare because it's powerful — there are no pictures in the way, just you telling the computer precisely what to do.

1. What Is the Command Line?

The command line is a text-based way to control your computer. Instead of clicking buttons and dragging files, you type an instruction, press Enter, and the computer carries it out immediately. Three words get used for closely related things, and it's worth pinning them down once:

TermWhat it isExamples
TerminalThe window or app you type intoiTerm2, GNOME Terminal, Windows Terminal
ShellThe program that reads and runs your commandsbash, zsh, fish, PowerShell
CLIThe general idea of typing commands instead of clickinggit, npm, docker

In casual conversation people mix these up constantly, and that's fine. The mental picture that matters: the shell (e.g. bash) runs inside the terminal window, and together they let you use the command line.

2. The Prompt — Where You Type

When you open a terminal, the shell shows a prompt — its way of saying "I'm ready, type something". It often ends in a dollar sign $ (or % on some Macs). The single most important rule for beginners: you don't type the prompt symbol. It's just the shell's marker for where your typing begins.

sam@laptop:~$ pwd
 |    |    | |  └── the command YOU type
 |    |    | └──── the prompt symbol (do NOT type this)
 |    |    └────── the folder you're in (~ means your home folder)
 |    └─────────── the computer's name
 └──────────────── your username

3. Why the Command Line Is So Powerful

If clicking is easier, why learn this? Because once a task can be typed, it can be repeated, combined, and automated — things a mouse can't do well.

4. Your First Command: echo

The friendliest place to start is echo, which simply prints text back to you. Wrap text in "double quotes" when it contains spaces or punctuation, so the shell treats it as one piece of text. Read this worked example, run it, and check your output matches.

# echo prints whatever text you give it straight back to the screen.
# It's the "Hello, World!" of the command line — safe and friendly.

echo Hello                    # one word -> no quotes needed
echo "Hello, command line!"   # quotes keep the spaces as ONE piece of text
echo "I am learning the CLI"  # punctuation is fine inside quotes too

Now you try. Fill in the blank marked ___ using the hint in the comment, then run it.

# 🎯 YOUR TURN — replace the ___ then run it in your terminal.

# 1) Print your own name to the screen.
echo ___          # 👉 put your name in "double quotes", e.g. "Alex"

# ✅ Expected output (example):
#    Alex

5. Where Am I & Who Am I? pwd, whoami, date

Three more safe, everyday commands answer questions about your current session. whoami prints your username, pwd (Print Working Directory) prints the folder you're currently "in", and date prints the system clock. None of them change anything — run them as often as you like.

Your turn again. One command is missing — fill in the ___ so the program prints your current folder and then your username.

# 🎯 YOUR TURN — one command is missing. Fill in the ___.

# 1) Ask the shell to print which folder you are currently in.
___               # 👉 the 3-letter "Print Working Directory" command

# 2) This one already works — it prints your username.
whoami

# ✅ Expected output (example):
#    /home/alex
#    alex

Pro Tip: the Tab key

Start typing a command or file name and press Tab — the shell finishes it for you (this is "tab completion"). Press Tab twice to see all the possibilities. It saves typing and prevents spelling mistakes, and it's one of the first habits that makes the terminal feel fast.

Common Errors (and the fix)

Run these to see the exact messages the shell gives back:

# Three mistakes every beginner makes — and what the shell says back.

# 1) A typo (or a tool that isn't installed):
ehco "hello"      # 'echo' misspelled as 'ehco'

# 2) Wrong capitalisation — the CLI is CASE-SENSITIVE:
PWD               # the real command is lowercase: pwd

# 3) A space in text without quotes splits it into separate arguments:
echo Hello    there   # the extra spacing is collapsed to one space

📋 Quick Reference

CommandWhat it doesExample output
echo "text"Print text to the screentext
pwdPrint the current folder/home/sam
whoamiPrint your usernamesam
datePrint the date and timeSun Jun 15 …
clearClear the terminal screen(blank screen)

Mini-Challenge: Your CLI Report

No blanks this time — just a brief and an outline to keep you on track. Use only the four commands you learned, run it, and check your output against the example in the comments.

# 🎯 MINI-CHALLENGE: A "who am I, where am I" report
# Using ONLY the four commands from this lesson, write commands that:
#   1. echo a heading line:  "--- My CLI report ---"
#   2. print your username
#   3. print the folder you are currently in
#   4. print the current date and time
#
# ✅ Expected output (example):
#    --- My CLI report ---
#    alex
#    /home/alex
#    Sun Jun 15 14:32:07 UTC 2026

# your commands here

🎉 Lesson Complete!

Practice quiz

What does the echo command do?

  • Deletes a file
  • Prints text back to the screen
  • Changes directory
  • Lists files

Answer: Prints text back to the screen. echo simply prints whatever text you give it to the screen.

Which command prints the folder you are currently in?

  • pwd
  • whoami
  • date
  • echo

Answer: pwd. pwd stands for Print Working Directory.

Which command prints your username?

  • pwd
  • date
  • whoami
  • ls

Answer: whoami. whoami prints the user account running the shell.

The command line is best described as a way to control your computer by what?

  • Clicking icons
  • Dragging windows
  • Voice commands
  • Typing text instructions

Answer: Typing text instructions. The CLI is a text-based way to control your computer by typing commands.

What is the program that reads and runs your commands called?

  • The shell
  • The mouse
  • The browser
  • The folder

Answer: The shell. The shell (such as bash) reads and runs your commands inside the terminal.

The dollar sign at the start of a command example is the prompt. Should you type it?

  • Always type it
  • No, you do not type it
  • Only on Windows
  • Only with echo

Answer: No, you do not type it. The $ is just the prompt; you never type it yourself.

Why should you wrap text with spaces in double quotes for echo?

  • To make it faster
  • To color the text
  • To keep it as one piece of text
  • To delete it

Answer: To keep it as one piece of text. Quotes keep spaced text together as a single argument.

What happens if you type EHCO instead of echo?

  • It runs anyway
  • It prints EHCO
  • It clears the screen
  • command not found

Answer: command not found. A typo gives bash: ehco: command not found.

The command line is case-sensitive, so typing PWD instead of pwd will do what?

  • Fail with command not found
  • Work the same
  • Print the date
  • Open an editor

Answer: Fail with command not found. PWD is not pwd; the CLI treats case as different, so it fails.

Which command shows the current system date and time?

  • pwd
  • date
  • whoami
  • echo

Answer: date. date prints the current date and time from the system clock.

Continue this course

Frequently asked questions

What is the difference between the terminal, the shell, and the command line?

The terminal is the window or app you type into (iTerm2, GNOME Terminal, Windows Terminal). The shell is the program running inside it that reads and runs your commands (bash, zsh, PowerShell). The command line (or CLI) is the general idea of controlling a computer by typing text instead of clicking. In everyday speech people use all three interchangeably, and that's usually fine.

Do I need to install anything to follow this lesson?

On macOS and Linux a terminal and shell are already built in — just open the Terminal app. On Windows the friendliest options are Git Bash (installed with Git from git-scm.com) or WSL (Windows Subsystem for Linux), both of which give you the same bash commands shown here. You can also paste any command into a free online bash runner to try it instantly.

What is the dollar sign ($) at the start of command examples?

The $ is the prompt — the shell's way of saying 'I'm ready for a command'. You do not type it. When a tutorial shows '$ pwd', you only type 'pwd' and press Enter. Some systems show a different prompt symbol such as % or >, but it means the same thing.

Will typing commands break my computer?

The commands in this lesson — echo, pwd, whoami, and date — only read information or print text. None of them change or delete anything, so they are completely safe to run as often as you like. As you learn commands that do change files later, you'll always be told which ones to be careful with.