pwd & ls
Where am I?
Lesson 1 of 20 · 6 min · Module 1: Find your way around
A terminal is a conversation with a computer. You type a command, press Enter, and the computer answers with text. Every command runs somewhere: in your current folder.
Start this lesson →Free. No installation: you write and run the code in your browser, and it is checked automatically.
By the end, you’ll be able to…
- Read a terminal prompt
- Show the current folder
- List a folder with and without moving
The idea
pwd (print working directory) shows the folder you are in. ls lists what that folder contains. Give ls a folder name, like ls projects, to look inside another folder without moving.
pwd
ls
ls projects
01Read the prompt
The prompt learner@codetemper:~$ tells you three things: the user name (learner), the computer name (codetemper), and the current folder. The ~ symbol is short for your home folder, /home/learner. The $ means the shell is ready for a command.
02A path is an address
/home/learner is an absolute path: it starts at the root folder / and names every folder on the way. pwd always prints the full absolute path, so you never have to guess.
pwd/home/learner03Look before you move
ls on its own lists the current folder. ls projects lists a different folder but leaves you where you are. Looking first is a good habit before you change or delete anything.
ls projectsscripts websiteYour turn
pwd. List your home folder with ls. Then list the contents of the projects folder.What the checks look for
- Shows the current folder: /home/learner
- Lists the home folder
- Lists the projects folder
Take this with you
pwd answers "where am I?" and ls answers "what is here?".
Go a little further
List the data folder too, and notice which names look like files and which look like folders.