Skip to content

Your first commands: pwd, ls and echo

Lesson 1 of 164 min

Type your first Linux commands in a practice terminal in your browser: read the prompt, print where you are with pwd, list files with ls, echo text.

The terminal is a conversation in text. You type a command, press Enter, and a program called the shell (on most Linux systems it's bash) runs it, prints what it has to say, and waits for the next one.

Reading the prompt

The line the shell shows while it waits is the prompt:

learner@sandbox:~$
  • learner is the user you're logged in as.
  • sandbox is the computer's name.
  • ~ is the directory (folder) you're in. ~ is short for your home directory, the one place on the system that belongs to you.
  • $ means the shell is ready for a command.

Three commands to start with

pwd (print working directory) prints where you are, as a full path from the top of the system:

pwd

ls (list) shows what's in the directory you're in. Folders appear in blue:

ls

echo prints back whatever you give it. It sounds useless, but you'll use it to write files and check variables later:

echo Hello, terminal

Good to know

  • Commands are case-sensitive: ls works, LS doesn't.
  • A typo gets command not found. Nothing breaks; press ↑ to bring the command back, fix it and press Enter again.
  • clear (or Ctrl+L) empties the screen, and help lists every command this practice terminal knows.

Your turn

Print where you are with pwd, list your home directory with ls, then make the terminal say hello with echo.

Next →