Your first commands: pwd, ls and echo
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:~$
learneris the user you're logged in as.sandboxis 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:
pwdls (list) shows what's in the directory you're in. Folders appear in blue:
lsecho prints back whatever you give it. It sounds useless, but you'll use it to write files and check variables later:
echo Hello, terminalGood to know
- Commands are case-sensitive:
lsworks,LSdoesn'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, andhelplists 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.
Your task
Print where you are with pwd, list your home directory with ls, then make the terminal say hello with echo.
- Print the working directory (pwd) (not done yet)
- List your home directory (ls) (not done yet)
- Print some text with echo (not done yet)
The checklist ticks itself off as you work in the terminal: any way that gets the result counts.
Hints come one at a time, then one way to do it. Try each before the next.
What this lesson uses, in one place.
pwd- Print the current (working) directory
ls- List the files and folders in a directory More on ls →
echo- Print a line of text More on echo →