Introduction

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.

Learn Python, JavaScript, Java and more with free interactive lessons, real projects and AI-powered help. Beginner-friendly.

Part of the free Cli course at LearnCodingFast — hands-on lessons with examples you run in your browser, 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 .

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:

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.

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.

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

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.

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.

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

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.

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.