Working with Windows Files via /mnt

Working with Windows Files via /mnt

Windows Files in Linux

Understanding /mnt in WSL

In WSL, your Windows file system is accessible through the /mnt directory. This allows you to work with your Windows files using Linux commands.

Drive Mounting

Windows drives are mounted as:

  • /mnt/c - C: drive
  • /mnt/d - D: drive
  • /mnt/e - E: drive (if exists)

Accessing Your Windows Files

Navigate to Windows Drive

cd /mnt/c
ls

Common Windows Paths

Windows PathWSL Path
C:\Users\YourName/mnt/c/Users/YourName
C:\Program Files/mnt/c/Program Files
C:\Windows/mnt/c/Windows
C:\Users\YourName\Documents/mnt/c/Users/YourName/Documents

Practical Examples

Example 1: Access Your Documents

cd /mnt/c/Users/YourName/Documents
ls

Example 2: Create a Project Folder

cd /mnt/c/Users/YourName/Projects
mkdir my-wsl-project
cd my-wsl-project

Example 3: Copy Files Between Locations

# Copy from Windows desktop to Linux home
cp /mnt/c/Users/YourName/Desktop/notes.txt ~/

Copy from Linux to Windows

cp ~/my-script.sh /mnt/c/Users/YourName/Scripts/

File Permissions in /mnt

Important Notes:

  • Files in /mnt have different permissions
  • Some Windows system files may be read-only
  • File execution permissions may differ
  • Symbolic links may work differently

Checking Permissions

ls -la /mnt/c

Working with Code Files

Edit Windows Files with Linux Tools

You can use Linux text editors to work with Windows code:

# Using nano (beginner-friendly)
nano /mnt/c/Projects/myproject/index.html

Using vim (advanced)

vim /mnt/c/Projects/myproject/script.js

Run Windows Executables

You can even run Windows .exe files from WSL:

/mnt/c/Program Files/Notepad++/notepad++.exe

Or using cmd.exe or powershell.exe:

cmd.exe /c notepad

Best Practices

DO:

✅ Keep your projects in /mnt/c/Users/YourName/Projects for easy access ✅ Use Linux tools for file manipulation ✅ Back up important files regularly

DON'T:

❌ Don't modify Windows system files in /mnt/c/Windows ❌ Don't rely on Linux file permissions for security ❌ Don't store WSL-specific files in /mnt (use ~/ instead)

The 9FS File System

WSL also allows accessing Windows files using 9P protocol:

# Mount Windows home to Linux home (advanced)
sudo mount -t 9p //home /mnt/wsl/9p -o trans=virtio

For most users, /mnt/c is sufficient.

Summary

The /mnt directory is your gateway to Windows files:

  • Navigate with cd /mnt/c/Users/YourName
  • List files with ls
  • Copy files with cp and mv
  • Edit with Linux text editors
  • Run Windows programs when needed
This integration makes WSL powerful for developers who need both worlds.

Next Lesson

In the next lesson, you'll learn how to install software using the apt package manager.

Quiz - Quiz - Working with Windows Files via /mnt

1. How do you access the Windows C: drive in WSL?

2. What is the path to a Windows user's Documents folder?

3. Can you run Windows .exe files from WSL?

4. Which command copies a file to your Windows desktop?

Navigating the File System