Skip to lesson

Moving around folders

I'm on:

Showing steps for Windows. They are marked “On Windows” below.

Every file lives in a folder, and folders sit inside other folders like the branches of a tree. The terminal always works inside one of those folders, and three short commands tell you where you are, what is there and how to move.

Where am I? The working directory

The working directory, or current folder, is the folder the terminal is working in right now. Commands look for files there unless you give them another path.

Priya types javac Hello.java and gets file not found, though the file is on her Desktop. The terminal was looking in another folder. pwd (print working directory) shows which one.

On Windows

A new PowerShell window starts in your home folder. You can also open PowerShell right inside the folder you want:

  1. Open the folder in File Explorer.
  2. Right-click an empty space in it → Open in Terminal.
  3. Or click File Explorer's address bar, type powershell and press Enter.

Example 1 · Print the working directory

Windows PowerShell
PS C:\Users\Priya> pwdPath
----
C:\Users\Priya

What this code does

  • PowerShell prints the current folder under the heading Path. A new window starts in your home folder, C:\Users\Priya.
  • The prompt PS C:\Users\Priya> already shows the same folder, so in PowerShell a glance at the prompt is often enough.

What is here? ls

ls (list) shows the files and folders inside the working directory, so you can check that a file is really where you think it is.

On Windows

In PowerShell, ls prints a table. Priya is in her home folder:

Windows PowerShell
PS C:\Users\Priya> ls    Directory: C:\Users\Priya


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----        21-10-2026     10:12                college-projects
d-r---        14-10-2026     09:30                Desktop
d-r---        14-10-2026     09:30                Documents
d-r---        20-10-2026     18:44                Downloads
  • A d at the start of Mode means a folder; -a---- means a file. Length is a file's size in bytes.
  • Names that start with a dot, like .gitignore, may be hidden. ls -Force shows hidden items too. (ls -a, from Mac guides, is an error in PowerShell.)

Move with cd

A path is the address of a file or folder: the folder names from the top down, joined by slashes. For example C:\Users\Priya\college-projects on Windows, or /Users/priya/college-projects on a Mac.

cd (change directory) takes a path and moves the terminal there. Two short names help: .. means one level up, and ~ means your home folder.

On Windows

Priya's folders on Windows. Wherever she is, cd .. goes up one level and cd ~ goes home.

A folder tree: C:\Users\Priya (the home folder, ~) holds Desktop, Documents and college-projects. college-projects holds java-basics and marks.txt. You are in college-projects. cd java-basics goes down into java-basics, cd .. goes up to the home folder, and cd ~ goes home from anywhere.

Example 2 · Down, up and home again

Windows PowerShell
PS C:\Users\Priya> cd college-projectsPS C:\Users\Priya\college-projects> cd java-basics
PS C:\Users\Priya\college-projects\java-basics> cd ..
PS C:\Users\Priya\college-projects> cd ~
PS C:\Users\Priya>

What this code does

  • Each cd prints nothing; instead the prompt changes to the new folder. Read the prompt to see where you are.
  • cd java-basics goes down into a folder inside this one, cd .. goes back up one level, and cd ~ jumps home from anywhere.

Absolute and relative paths

An absolute path starts at the top (C:\ on Windows, / on a Mac) and works from any folder. A relative path starts from the working directory, so its meaning changes when you move.

cd college-projects worked only because Priya was in her home folder, where college-projects sits. From any other folder she needs the full, absolute path.

On Windows

On Windows a path starts with a drive letter, and \ separates the names. From Documents, an absolute path goes straight to java-basics:

Windows PowerShell
PS C:\Users\Priya\Documents> cd C:\Users\Priya\college-projects\java-basics
  • cd prints nothing when it works; the prompt changes to show the new folder.
  • Another drive? cd D:\college moves to drive D: and its college folder in one step.
  • PowerShell also accepts / in paths, so cd college-projects/java-basics works too.
Two ways to name marks.txt. Absolute: C:\Users\Priya\college-projects\marks.txt starts at the top (C:\) and works from any folder. Relative: from college-projects (where you are) it is just marks.txt, and ..\Documents means up one level, then into Documents.

Names with spaces, and the Tab key

The shell splits a command at every space. So cd My Notes hands cd two words, My and Notes, and fails.

Example 3 · A space in the name

Windows PowerShell
PS C:\Users\Priya\college-projects> cd My NotesSet-Location : A positional parameter cannot be found that accepts argument 'Notes'.

What this code does

  • Set-Location is PowerShell's full name for cd. The message means: cd takes one folder, but it also got a second word, Notes.
  • cd "My Notes" passes the whole name as one word, and it works.

Put quotes around the name: cd "My Notes". Even easier, type cd My and press Tab: the shell finishes the name and adds the quotes for you. Tab works for every file and folder name, so use it all the time.

For your own projects, avoid spaces: college-projects or java_basics never need quotes.

Next step

Check your understanding

8 quick questions