If you see No such file or directory, the path you're trying to use doesn't exist.

First, check your spelling and try again:

ls /path/you/typed

If that fails, the file or folder really isn't there.

Common Causes

1. Typo in the path

cd ~/Docuemnts     # Wrong
cd ~/Documents     # Right

Terminal doesn't forgive typos.

2. Wrong directory

You might be in a different folder than you think:

pwd                 # Check where you are
ls                  # See what's here

3. File was moved or deleted

ls ~/Downloads/file.pdf    # Is it still there?

4. Case sensitivity

Terminal is case-sensitive by default on APFS:

cat README.md       # Works
cat readme.md       # Might fail

5. Spaces in the path

Paths with spaces need quotes or escaping:

cd ~/My Documents         # Wrong
cd ~/My\ Documents        # Right (escaped)
cd "~/My Documents"       # Right (quoted)

6. Tilde not expanding

The ~ shortcut only works at the start of a path and not inside quotes in some contexts:

cd ~                    # Works
ls ~/file.txt           # Works
ls "~/file.txt"         # Might fail - use "\$HOME" instead
ls "\$HOME/file.txt"     # Works

Finding the Right Path

Use tab completion

Start typing and press Tab:

cd ~/Doc<TAB>     # Completes to ~/Documents

If nothing happens, no match exists. Press Tab twice to see options.

Use drag and drop

Drag a file or folder from Finder into Terminal. It types the full path for you.

Use pwd

Always know where you are:

pwd

List directory contents

ls                      # Current directory
ls ~/                   # Home directory
ls -la                  # Including hidden files

Specific Errors

"bash: /some/path: No such file or directory"

The file you're trying to run doesn't exist:

which python          # Find where a command actually is
ls /usr/local/bin/    # Check if it's where you expect

"cd: no such file or directory"

The folder doesn't exist. Create it:

mkdir -p /path/to/folder

The -p flag creates parent directories too.

"open: no such file or directory"

The file isn't where you said:

find ~ -name "filename.txt"   # Search for it

Script says "file not found"

Check the path in the script. It might use a relative path that only works from a specific directory.

Finding Files

If you know the file exists but don't know where:

# Search by name
find ~ -name "filename.txt"

# Search for partial names
find ~ -name "*.pdf" | grep report

# Use Spotlight from Terminal
mdfind "filename"

Hidden Files

Files starting with . are hidden. They exist but don't show in normal listings:

ls ~/.zshrc          # File exists
ls ~/                # Doesn't show .zshrc
ls -a ~/             # Shows hidden files

Path Variables

If a command can't find a file it needs, check your PATH:

echo \$PATH

This shows directories where Terminal looks for commands.

Checking If Something Exists

Before running a command on a file:

test -f ~/file.txt && echo "exists" || echo "not found"
test -d ~/folder && echo "exists" || echo "not found"

Or:

ls /path/to/thing 2>/dev/null && echo "Found" || echo "Not found"

Keep Learning

Understanding paths and file locations is fundamental to using Terminal. The free course covers this and more.

Check it out at Mac Terminal for Humans.