Linux Command Line for Beginners › Module 1: Getting Started › Lesson 1.2

Your First Commands

Free previewLesson 1.2 · about 25 minutes · 5 exercises

0 of 5 exercises completed
Every terminal on this page is live: click in it and type

Get the full course

10 modules of hands-on Linux command line skills — a live practice terminal inside every lesson, in your browser, nothing to install. Lessons 1.1 and 1.2 are free; the rest of the course is Rs. 300 + 18% GST.

Enroll Now — Rs. 354.00

By the end of this lesson you will be able to

  • read the prompt and say what each part of it means
  • run a command, give it options and arguments, and read its reply
  • use whoami, date, echo, clear and history
  • keep spaces in text with quotation marks
  • bring back earlier commands with the up arrow and with !
How the exercises work

Every terminal on this page is a live pretend computer that runs inside your browser. Click inside one, type a command and press Enter. Nothing you type can harm your own computer. In each exercise, do the task and then press Check my answer. If you get stuck, Show solution shows one correct answer, and Reset puts the terminal back as it started.

Harriet's first morning

Harriet Cole has just joined Larkspur Press, a small publisher, as office assistant. The press keeps its manuscripts, invoices and records on one office computer called larkspur, and George Whitfield, the office manager, looks after it. On her first morning George pulls up a chair beside her.

“Most of what we do on this machine,” he says, “we do by typing. It looks bare at first, but it is quicker than clicking once you know a dozen commands. Let's start with the line you type on.”

The prompt

When the terminal is ready for you, it shows a prompt. On Harriet's computer it looks like this:

harriet@larkspur:~$
PartWhat it tells you
harrietwho you are: the user name you logged in with
@larkspurwhich computer you are working on
~which folder you are in. ~ is short for your own home folder. Module 2 is all about folders.
$the shell is waiting for you. (It becomes # for the all-powerful root user, whom you will meet in Module 7.)

Prompts vary from computer to computer, but they nearly always end in $ and nearly always show your name and folder somewhere. In these lessons we print commands after a $, with the computer's reply underneath. You never type the $ yourself: type only what comes after it.

Your first command: whoami

A command is a word, typed at the prompt and followed by Enter. The shell finds the program with that name, runs it, and prints whatever the program says. Try the simplest one there is. It prints your user name:

$ whoami
harriet

Then try date, which prints today's date and the time:

$ date
Mon Mar  2 09:00:07 UTC 2026

Your seconds will be different, because the clock moves on. Try both in the terminal below. You can type them, or press the buttons, which type for you.

Common mistake: capital letters

$ Date
bash: Date: command not found

Linux treats capital and small letters as different, so Date and date are two different names, and only one of them exists. Nearly all commands are written entirely in small letters. The message “command not found” almost always means a typing slip, so look at what you typed before anything else.

Options and arguments

Many commands can be told what to do. Anything you type after the command's name, separated by spaces, is passed to it. There are two kinds:

date takes a special kind of argument that starts with + and describes the layout you want. %F means “the full date, year first”, and %A means “the name of the day”:

$ date +%F
2026-03-02
$ date +%A
Monday

The spaces matter. date +%F is a command and one argument; date+%F, with no space, is one long word that the shell cannot find.

Printing text: echo

echo prints back whatever you give it. That sounds pointless, but you will use it constantly: to write notes into files, to check what the shell will do with your typing, and to print messages from scripts.

$ echo Hello, Larkspur Press
Hello, Larkspur Press

Each word after echo is a separate argument, and echo prints them with one space between each. So extra spaces vanish:

$ echo Room     4
Room 4
$ echo "Room     4"
Room     4

In the second command the quotation marks tell the shell that everything inside them is one single argument, spaces and all. You will need quotes whenever text contains spaces or characters that mean something special to the shell, such as *, & or ;. Single quotes 'like this' work too, and are even stricter: the shell changes nothing at all inside them. Use single quotes for text containing !, because inside double quotes the shell still treats ! as a way of recalling an earlier command (you will see why at the end of this lesson). If you forget the closing quote, the shell waits for more with a > prompt. Type the closing quote and press Enter to finish.

Clearing the screen and looking back

When the screen gets crowded, clear wipes it (Ctrl+L does the same). Nothing is lost: the shell remembers every command you have typed. history lists them with numbers (the history command itself is the newest entry):

$ history
    1  whoami
    2  date
    3  echo Hello, Larkspur Press
    4  history

There are three quick ways to repeat a command:

You typeWhat happens
the up arrow keybrings back the previous command so that you can edit it or press Enter to run it again. Press it again to step further back, and the down arrow to come forward.
!!runs the last command again
!2runs command number 2 from the history list again

When you use !, the shell first prints the command it is about to run, so that you can see what happened. The up arrow is the one you will use most, dozens of times a day.

On a real computer

Everything in this lesson works the same way in a terminal on any Linux computer, and in the terminals of most other modern computers too. The practice terminal's clock is fixed to a Monday morning in March, so its dates will not match your calendar.

Exercises

Each exercise starts with a fresh terminal. Read the task, type your commands, then press Check my answer.

Exercise 1 · Who and when

George asks Harriet to check that she is logged in under her own name. Run the command that prints your user name, and then the command that prints the date and time.

Exercise 2 · Say it with echo

Use echo to print this line exactly, with its capital letters and full stop:

Good morning from Larkspur Press.

Exercise 3 · Keep the spaces

The label on the stationery cupboard must have five spaces between the word and the number, like this:

Shelf     B

Print it with echo, keeping all five spaces.

Exercise 4 · Today in a tidy format

George names his daily notes with the date written year first, like 2026-03-02. Make date print today's date in exactly that form, and nothing else.

Exercise 5 · Once more, from the history

Someone has already used this terminal. Look at the list of earlier commands, find the one that printed a message about the print queue, and run it again without typing the message out yourself. Use the up arrow, !! or ! with a number.

0 of 5 exercises completed

Quick check

Four questions to confirm the main ideas. Choose an answer to see the explanation.

The prompt reads harriet@larkspur:~$. What does the ~ tell you?

What does echo Room     4 print (with five spaces typed, and no quotation marks)?

You type Whoami and see command not found. Why?

What does !! do?

Summary

  • The prompt shows who you are, which computer and which folder, and ends in $ when the shell is waiting for you.
  • A command is a name followed by options (which change how it works, such as -l) and arguments (which say what to work on).
  • whoami prints your user name, date the date and time, and echo prints its arguments back.
  • Commands are case-sensitive. Quotation marks keep text with spaces together as one argument.
  • clear wipes the screen. history lists earlier commands; the up arrow, !! and !N run them again.

Found a mistake on this page, or something unclear? Report a problem and mention “Linux Lesson 1.2”.