ThisCalculator

Everyday

How to Navigate to a Folder in Terminal on Mac

Updated · Standard formula, shown below

This guide shows you how to move between folders (directories) using the Terminal app on a Mac. You’ll learn the essential cd command, how to use relative and absolute paths, and how to handle paths with spaces. By the end, you’ll be able to navigate your Mac’s file system quickly and confidently from the command line.

What You’ll Need

  • A Mac running macOS (any recent version).
  • Terminal app, located in Applications > Utilities or via Spotlight (press Cmd+Space and type “Terminal”).
  • Basic familiarity with your Mac’s folder structure (e.g., Home, Documents, Desktop).

Step-by-Step

  1. Open Terminal. Launch Terminal from Applications > Utilities, or use Spotlight. You’ll see a window with a command prompt, usually ending with ~ (your home directory).
  2. Check your current location. Type pwd (print working directory) and press Return. This shows the full path of the folder you’re currently in. For example, /Users/yourname.
  3. List the contents. Type ls and press Return to see all files and folders in the current directory. This helps you know what folders you can navigate into.
  4. Use the cd command to change directory. The basic syntax is cd [path]. For example, to go into your Documents folder, type cd Documents and press Return.
  5. Navigate with relative paths. You can use . for the current folder, .. for the parent folder, and ~ for your home folder. For example, cd .. moves up one level, cd ../.. moves up two levels, and cd ~/Desktop goes directly to your Desktop.
  6. Use absolute paths. An absolute path starts from the root directory (/). For example, cd /Users/yourname/Movies will take you to your Movies folder regardless of where you are. You can find the full path by dragging a folder into the Terminal window—it will automatically insert the path.
  7. Handle paths with spaces. If a folder name has spaces, enclose the path in quotes: cd "My Folder" or escape each space with a backslash: cd My\ Folder. For example, cd "/Users/yourname/Library/Application Support".
  8. Use Tab completion. Type the first few letters of a folder name and press Tab to auto-complete it. If there are multiple matches, press Tab again to see them. This saves time and avoids typos.
  9. Go directly to a subfolder. You can chain paths: cd Documents/Projects/Website will go straight to the Website folder if it exists.
  10. Return to your home directory. Simply type cd with no arguments, or cd ~, to go back to your home folder.

Common Mistakes

  • Forgetting to press Return. Commands don’t execute until you press Return.
  • Using forward slashes instead of backslashes. macOS uses forward slashes (/) in paths, not backslashes.
  • Spelling errors. Folder names are case-sensitive. Documents is different from documents.
  • Not quoting paths with spaces. Typing cd My Folder will fail because cd sees two arguments. Use quotes or escape spaces.
  • Using cd to run a program. cd only changes the directory; it doesn’t execute files. Use ./program to run something in the current folder.

Tips

  • Use drag-and-drop. Drag any folder from Finder into Terminal to insert its full path automatically. This is especially useful for deep or hidden folders.
  • Create aliases. Add shortcuts to your .bash_profile or .zshrc file, e.g., alias docs='cd ~/Documents' to jump quickly.
  • Use open . to open the current folder in Finder. This helps you see the graphical representation of where you are.
  • Use cd - to toggle between your last two directories. This is handy when you’re working in two locations.
  • Remember that ~ always refers to your home folder. It works in any path, e.g., cd ~/Downloads.

Troubleshooting

  • “No such file or directory” error. This means the path you typed doesn’t exist. Check spelling, case, and whether you’re in the right parent directory. Use ls to see what’s actually there.
  • “Permission denied” error. You may not have access to that folder. Try sudo cd (not recommended) or use Finder to check permissions. For system folders, you might need to use sudo with the command you run inside, not with cd itself.
  • Command not found. If you see bash: cd: command not found, your shell environment is broken. Try opening a new Terminal window or restarting Terminal.
  • Terminal doesn’t respond. Press Ctrl+C to cancel a running process, or type exit and reopen Terminal.
  • Path with spaces still fails. Make sure you’re using straight quotes (“) not curly quotes. If you’re escaping spaces, ensure there’s no space after the backslash.

Frequently Asked Questions

What does cd stand for?

cd stands for “change directory”. It’s the command used to move between folders in a terminal.

How do I go back to the previous folder?

Use cd - to switch to the last directory you were in. Alternatively, use cd .. to go up one level.

How do I navigate to a folder on another drive?

On macOS, other drives are usually mounted under /Volumes/. For example, cd /Volumes/MyDrive/Folder.

Can I use Terminal to navigate to a folder with a space in its name?

Yes, enclose the path in quotes: cd "My Folder" or escape the space: cd My\ Folder.

Why does cd not work when I type a folder name that is a file?

cd only works on directories (folders). If you try to cd into a file, you’ll get a “Not a directory” error. Use open filename to open a file.

How do I see hidden folders in Terminal?

Use ls -a to list all files, including hidden ones (those starting with a dot). Hidden folders like .ssh or .config are visible this way.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.