How to Import Files from Your Laptop into WSL (Windows Subsystem for Linux)

Posted by

Limited Time Offer!

For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly.
Master DevOps, SRE, DevSecOps Skills!

Enroll Now

Working with WSL is powerful because you can use Linux tools directly on your Windows machine. One of the most common needs is moving or copying files from the Windows side into the WSL Linux environment.
This tutorial covers every method, answers all common questions, and explains why certain approaches are better.


1. Understanding How WSL Sees Windows Files

When WSL is installed, Windows automatically exposes its drives inside Linux.
This means:
C: drive appears as /mnt/c
D: drive appears as /mnt/d

For example:

  • A file on your Desktop:
    Windows: C:\Users\YourName\Desktop\sample.txt
    WSL: /mnt/c/Users/YourName/Desktop/sample.txt

This is the foundation of everything.
Once you understand this, file transfer becomes very easy.


2. Method 1: Direct Copy Using Linux Commands (Recommended)

This is the most stable and universal method.

Step-by-step:

  1. Identify your Windows file path.
    Example: C:\Users\Rajesh\Desktop\data.csv
  2. Convert it to WSL path:
    /mnt/c/Users/Rajesh/Desktop/data.csv
  3. Copy it into WSL home directory:
cp /mnt/c/Users/Rajesh/Desktop/data.csv ~/

Now data.csv is inside Linux at:

/home/<your-wsl-username>/data.csv

Why this method is best:

  • Works on WSL1 and WSL2
  • No GUI required
  • Fast and reliable
  • Supports large files

3. Method 2: Drag and Drop into Terminal (WSL2 on Windows 11 Only)

If you are using Windows 11 with WSLg (GUI support):

  1. Open your WSL terminal.
  2. Drag a file from Windows File Explorer.
  3. Drop it into your WSL shell window.

WSL copies the file into the current directory.

This is extremely easy, but only available in the latest WSL version.


4. Method 3: Using explorer.exe from WSL

WSL can open a Windows File Explorer window directly inside your Linux location.

Example:

explorer.exe .

This opens the current WSL folder in Windows Explorer.

How to use this to import files:

  1. Go to your desired folder in WSL terminal.
  2. Run:
explorer.exe .
  1. A Windows folder opens.
  2. Copy/paste files into it normally.

All pasted files instantly appear in WSL.

This is perfect for users who prefer GUI instead of commands.


5. Method 4: Copy via PowerShell or CMD

If you are already in PowerShell or CMD, you can copy files into WSL without opening the terminal.

Examples:

Copy from Windows to WSL home:

wsl cp "/mnt/c/Users/Rajesh/Desktop/info.txt" "/home/rajesh/"

Or copy from WSL to Windows:

wsl cp "/home/rajesh/test.jpg" "/mnt/c/Users/Rajesh/Desktop/"

This is useful during automation or scripting.


6. Method 5: Shared Location (Both Sides Can Access)

Because WSL can access anything under /mnt/c, one easy method is:

  1. Create a folder in Windows:
    Example: C:\wsl_shared
  2. Inside WSL, this folder is visible at:
    /mnt/c/wsl_shared
  3. You can drop files from Windows into this folder and then use them in WSL.

This is ideal if you move files frequently.


7. Frequently Asked Questions (FAQ)

Q1: Do I need to install anything extra to transfer files?

No. WSL automatically mounts Windows drives at /mnt/c, /mnt/d, and so on.


Q2: Can WSL access the entire Windows file system?

Yes. Everything on your Windows drives is accessible from WSL.


Q3: Will copying files this way cause data corruption?

No. Copying files between Windows and WSL is safe and fully supported.


Q4: Can I open Windows folders directly from WSL?

Yes. Use:

explorer.exe .

Q5: Can I edit Linux files using Windows apps?

Yes, but be careful editing files inside WSLโ€™s Linux root.
For best safety, edit files stored inside /mnt/c/....


Q6: Can I move a whole directory from Windows to WSL?

Yes:

cp -r /mnt/c/Users/Rajesh/Desktop/myfolder ~/

Q7: Can I do this the opposite way (WSL โ†’ Windows)?

Yes:

cp ~/output.log /mnt/c/Users/Rajesh/Desktop/

Q8: Is drag & drop supported?

Only on WSL2 with Windows 11 and WSLg enabled.


Q9: What if my username has spaces?

Use quotes:

cp "/mnt/c/Users/Rajesh Kumar/Desktop/file.txt" ~/

8. Best Practices & Recommendations

  1. Use /mnt/c/... paths for quick access.
  2. Use explorer.exe . when you want simplicity.
  3. Avoid storing project files under WSL root (/home) if you want to edit using Windows apps.
  4. Prefer Method 1 for scripting and repeatable tasks.
  5. Prefer Method 3 if you prefer GUI.

9. Summary Table (Quick Comparison)

MethodBest ForProsNotes
Direct copy via /mnt/cEveryoneFast, stableWorks on all WSL versions
Drag-and-dropWindows 11Very easyRequires WSLg
explorer.exe .GUI usersSeamless copy/pasteBest for large directory transfers
PowerShell wsl cpAutomationScriptableRequires correct paths
Shared folderFrequent transfersPermanent workspaceGreat for mixed Windows/Linux workflows

Leave a Reply

Your email address will not be published. Required fields are marked *

0
Would love your thoughts, please comment.x
()
x