How to Use pwd, cd, and ls - Linux Basic Commands Tutorial
What you'll be able to do
- Check where you are with pwd
- List files and directories with ls -la
- Move with cd and fix No such file or directory yourself
Prerequisites (read these first)
What You'll Learn
Conclusion: pwd, ls, and cd give location, contents, and movement — the three core commands.
- Check "where you are" with
pwd - See "what's here" with
ls - Navigate anywhere with
cd - Fix "No such file or directoryA container that organizes files. Same idea as a "folder" on Windows or macOS." errors on your own
Target Audience: First-time Linux command users, those nervous about the terminalAn interactive program that reads the commands you type and runs them.
All three commands in this article only show things and move you around. None of them delete or change a file. You can mistype them as often as you like, and your machine stays safe.
Introduction: Lina's First Stumble
Conclusion: Lina hits the terminal and learns why pwd, ls, and cd are the starting point.
pwd (current location), ls (list), and cd (change directory). Once you know these, you won't get lost in the terminal.A note on words: terminal, shell, and console are three names for nearly the same thing. This article always says terminal. A terminal is the screen where you type a command and read the result as text.
pwd - Check Your Current Location
Conclusion: Run pwd first to know where you are — this single habit prevents most accidents.
pwd command. It tells you where you are right now.pwd is a habit that prevents that.Let's Try It
$ pwd
/home/user
Key Point: The output /home/user means you are in your home directory. The / is the Linux rootThe special administrator account allowed to do anything on the system., the topmost directory. From there you have gone through home and then user.
/home/user! So that's where I am right now?pwd to check.ls - See What's Here
Conclusion: ls shows directory contents; ls -la adds details and reveals hidden files too.
ls command. It shows you what's in your current location.ls first.Basic ls
$ ls
documents pictures downloads
ls -la more often.-l and -a you add after a command are called options. They are switches that change what the command does. The -l gives the detailed view, and -a shows hidden files too.Detailed View (ls -la)
$ ls -la
total 12 drwxr-xr-x 5 user user 4096 Feb 2 10:00 . drwxr-xr-x 3 user user 4096 Feb 2 10:00 .. drwxr-xr-x 2 user user 4096 Feb 2 10:01 documents drwxr-xr-x 2 user user 4096 Feb 2 10:01 pictures drwxr-xr-x 2 user user 4096 Feb 2 10:01 downloads
Key Point: You don't need to understand every column yet. Just remember these two.
- First character:
dmeans directory. A-means file. - Last name:
documentsorpicturesis the directory name. - The
.and..rows:.is a special name for the directory you are in, and..is a special name for the directory one level up. It is the same..you will see incd ..later.
A hidden file is a file whose name starts with .. Plain ls does not show it. It appears only when you add -a.
The total 12 on the first line is a sum of blocks. You can ignore it for now.
The rwxr-xr-x part is about permissions, which say who can read and write. You can learn that later.
pwd to check location, then ls -la to check contents. That's the basic pattern.cd - Navigate Directories
Conclusion: cd enters dirs; .. goes up one; ~ goes home; - returns to the previous place.
cd command. It lets you move between directories.cd documents.Move to a Directory
$ cd documents $ pwd
/home/user/documents
pwd, it shows /home/user/documents now.pwd after moving.Common Shortcuts
$ cd ~ # Go to home directory $ cd .. # Go up one directory $ cd - # Go back to previous location
.. is handy. It goes up one level?cd .. goes up one level, and cd ~ takes you straight home. Remember these to make navigation much easier.Common Pitfall: No such file or directory
cd dowloads and got "No such file or directory" error...ls -la first, then copy and paste it.Recovery Pattern:
- Check your location with
pwd. - Check the candidates with
ls -la. - Copy the exact directory name and run
cd.
Mini Challenges - Practice Now
Conclusion: Practice pwd, ls -la, and cd in mini challenges to lock in the core workflow.
Challenge 1: Check your location and list contents
Your task: show where you are, then show every file in that place with full details.
Show hint 1 (direction)
Use one command that answers "where am I", then one that answers "what is here". In that order.
Show hint 2 (command names)
The commands are pwd and ls. To see hidden files with details, add two options to ls.
Show the answer
$ pwd
/home/user
$ ls -la
total 12 drwxr-xr-x 5 user user 4096 Feb 2 10:00 . drwxr-xr-x 3 user user 4096 Feb 2 10:00 .. drwxr-xr-x 2 user user 4096 Feb 2 10:01 documents drwxr-xr-x 2 user user 4096 Feb 2 10:01 pictures drwxr-xr-x 2 user user 4096 Feb 2 10:01 downloads
Challenge 2: Move to documents directory and come back
Your task: move into documents, confirm the move, then go back up one level.
Show hint 1 (direction)
Alternate between the command that moves you and the command that confirms where you are. There is a short symbol that means "one level up".
Show hint 2 (command names)
The commands are cd and pwd. To go up one level, put .. after cd.
Show the answer
$ cd documents $ pwd
/home/user/documents
$ cd .. $ pwd
/home/user
cd ..!Challenge 3: Jump straight to home directory
Your task: from wherever you are, return to your home directory in one step.
Show hint 1 (direction)
You do not need to repeat cd ... There is a single symbol that means home.
Show hint 2 (command names)
The command is cd. Your home directory is written as ~, the tilde.
Show the answer
$ cd ~ $ pwd
/home/user
Today's 3-Line Summary
Conclusion: pwd, ls, and cd in 3 lines — the terminal foundation before anything else.
pwdchecks "where you are" (prevents getting lost)ls -lashows "what's here" in detail (including hidden files)cdto move,cd ..to go up,cd ~to go home
Practice these commands anytime in the interactive terminal.