How to Use pwd, cd, and ls - Linux Basic Commands Tutorial

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.

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.

Lina: Linny-senpai, where should I even start with Linux commands? When I open the terminal, I have no idea what to do...
Linny-senpai: I totally get it. Everyone feels that way at first. Just learn three things: "where you are," "what's here," and "how to move."
Lina: Just three?
Linny-senpai: Yep. 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.

Linny-senpai: First up is pwd command. It tells you where you are right now.
Lina: Why is that important?
Linny-senpai: In the terminal, the directory you are in matters a lot. A directory is the same thing as a folder in Windows or on a MacA system-wide access control model enforced by fixed rules (Mandatory Access Control)..
Linny-senpai: If you delete or create files in the wrong place, it can be a disaster. Checking with 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.

Lina: I got /home/user! So that's where I am right now?
Linny-senpai: Exactly. Whenever you're lost, just run pwd to check.

ls - See What's Here

Conclusion: ls shows directory contents; ls -la adds details and reveals hidden files too.

Linny-senpai: Next is ls command. It shows you what's in your current location.
Lina: So it shows the contents of where I am?
Linny-senpai: Exactly. Try the basic ls first.

Basic ls

$ ls
documents  pictures  downloads
Lina: I see three directories! But I can't get detailed info with just this...
Linny-senpai: Good observation. As you get used to it, you'll reach for ls -la more often.
Linny-senpai: The -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: d means directory. A - means file.
  • Last name: documents or pictures is 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 in cd .. 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.

Lina: I see! Now I can see detailed information.
Linny-senpai: Right. When in doubt, first 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.

Linny-senpai: Last is cd command. It lets you move between directories.
Lina: I want to move into the documents directory I saw earlier!
Linny-senpai: OK, try typing cd documents.

Move to a Directory

$ cd documents
$ pwd
/home/user/documents
Lina: I moved! When I checked with pwd, it shows /home/user/documents now.
Linny-senpai: Perfect. Get in the habit of always checking with pwd after moving.

Common Shortcuts

$ cd ~      # Go to home directory
$ cd ..     # Go up one directory
$ cd -      # Go back to previous location
Lina: Oh, .. is handy. It goes up one level?
Linny-senpai: Yep. 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

Lina: Wait, I typed cd dowloads and got "No such file or directory" error...
Linny-senpai: That's a common one. It's not "dowloads," it's "downloads." Almost every one of these errors is a typo.
Linny-senpai: Check the exact directory name with ls -la first, then copy and paste it.
Lina: I see! If I check first and copy-paste, I won't make mistakes.

Recovery Pattern:

  1. Check your location with pwd.
  2. Check the candidates with ls -la.
  3. 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.

Linny-senpai: Let's try some challenges using these three commands. Think it through before you open the answer.

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
Lina: Done! I can see my current location and contents.

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
Lina: I moved and came back with 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
Linny-senpai: Perfect. Once you can use these three commands, you won't get lost in the terminal.
Lina: Yay! The terminal doesn't scare me anymore!

Today's 3-Line Summary

Conclusion: pwd, ls, and cd in 3 lines — the terminal foundation before anything else.

  • pwd checks "where you are" (prevents getting lost)
  • ls -la shows "what's here" in detail (including hidden files)
  • cd to move, cd .. to go up, cd ~ to go home

Practice these commands anytime in the interactive terminal.

Next Reading

Conclusion: Next: learn file creation, copying, and deletion to complete the basics.

Lina: After mastering these three commands, what should I learn next?
Linny-senpai: File operations. Creating, copying, and deleting files. I'll teach you in dialogue format again in File Operations Basics, so look forward to it.
Share this article

Next steps