![Warp Terminal](/assets/images/warp.webp)
Among its numerous advantages, one notable feature is the seamless accessibility of Linux files stored within WSL from the Windows operating system itself.
In this article, you'll explore various methods of accessing WSL files. This will enable smooth file management and interoperability between Windows and Linux environments.
You will look at both graphical and command-line ways of accessing WSL files inside Windows.
Access WSL files using Windows Explorer
The most basic way of accessing a file on Windows is by launching the Windows File Explorer. The file manager is present on the taskbar, and you can just open it to browse files. Wait! That is for Windows files, but for Linux?
Yes. WSL indeed stores the file inside Windows because it is the host. If you have set up the WSL correctly on Windows, you will see a Penguin icon on your File Explorer.
![Click on the penguin icon on the left sidebar of the File explorer](https://itsfoss.com/content/images/2024/03/click-on-penguin-icon.png)
Just click on it.
You will see the name of the WSL distributions you have installed currently as folders. I have two; an Ubuntu and an OpenSUSE Tumbleweeed.
![Double click on any of the folders to open the root directory of that WSL distribution.](https://itsfoss.com/content/images/2024/03/click-on-any-of-the-distribution-inside-the-linux-mount.png)
Double-click on the one you need to access. Now, you are inside the root directory of that system.
![Inside the root directory of the distribution](https://itsfoss.com/content/images/2024/03/inside-the-root-file-of-the-distribution-infile-explorer.png)
Go inside the home β username folder, and there it is.
![Home directory of the default user in Windows file explorer](https://itsfoss.com/content/images/2024/03/home-directory-in-windows-file-explorer.png)
You are now accessing the home directory of the default user. Double-click on any file to open it on a Windows app. You can see in the screenshot below, I have opened the .bashrc
file on Notepad app.
![Open the bashrc file of the WSL distribution using Windows Notepad application](https://itsfoss.com/content/images/2024/03/open-bashrc-file-in-windows.png)
.bashrc
file in NotepadUse the address bar of Explorer
You can use the address bar of Windows Explorer to go into the WSL folders. For this, click on the to address bar. When it is changed to editing, enter:
\\wsl$
![Enter the WSL location in the address bar of Windows file explorer](https://itsfoss.com/content/images/2024/03/enter-wsl-in-addreess-bar-of-explorer.png)
This will bring you to the same folder, where all the WSL distributions are listed as folders. Click on any to enter into it.
![Click on the folder with the name of the WSL distro on which you want to browse a file](https://itsfoss.com/content/images/2024/03/click-on-any-to-enter-into-that-distro.png)
π‘ Tip: Open the current Linux directory location in Windows
Imagine that you are using Linux through the Windows terminal and you are in a specific directory location. Now, you think it would be better if you could access it in the file explorer.
This is possible and quite easy. Enter the following command on the WSL terminal.
explorer.exe .
Here, the .
refers to the current directory you are in. This means that your current directory will be opened in the Windows file explorer.
![Opening the present directory you are visiting in a WSL distribution using the Windows file explorer.](https://itsfoss.com/content/images/2024/03/run-explores-exe-in-a-directory-to-open-that-directory-in-explorer.png)
Similarly, while inside the WSL, you can specify a directory path to open that folder in Windows Explorer.
![Open a particular WSL directory using Windows Explorer by providing the exact path too that directory](https://itsfoss.com/content/images/2024/03/give-a-directory-path-as-parameter-to-explorer-exe.png)
As you can see, the mentioned directory is opened in Windows Explorer and you can access the files.
Open a WSL text file in Notepad
While there are terminal-based text editors available in Linux, you may not be comfortable with the idea of editing files in the command line.
Thankfully, you can easily open those Linux text files using Windows's Notepad.
notepad.exe /path/to/the/file/inside/wsl/distribution
![Open a text file inside a WSL distribution directory using Windows Notepad](https://itsfoss.com/content/images/2024/03/opening-a-wsl-text-file-using-windows-notepad.png)
Accessing files between WSL and Windows
As you can easily guess by now, it is possible to access files between WSL and the Windows host operating system.
Here are a few tips on accessing files between Windows and Linux inside WSL.
Edit Windows files inside WSL
While inside WSL, you can open a file stored on the Windows filesystem using Linux tools like the Nano editor.
For this, we use the Mounted Drive concept.
nano /mnt/c/Users/username/Documents/filename
![Files in Windows is edited using the nano editor inside the WSL distribution](https://itsfoss.com/content/images/2024/03/files-on-windows-edited-inside-wsl.png)
Here, the /mnt/c
represents the C drive mounted to the WSL. So, what the command actually does is, open the specified file on the location specified in nano editor.
You can use /mnt/d
, if you have a drive located with D:
in Windows.
Copy files between WSL and Windows
Inside the WSL, you can copy a file from WSL to a specified Windows folder. To do that, use the cp
command:
cp /home/$USER/filename /mnt/d/Documents/
This will copy the file called filename
from the home directory of the user to the Documents folder (if exists) on the D drive.
![Copy a file from WSL to a Windows folder](https://itsfoss.com/content/images/2024/03/transfer-file-from-WSL-to-windows-folder.png)
Similarly, if you want to transfer a file from a Windows folder into the WSL system, use:
cp /mnt/d/Documents/filename /home/$USER/
![Copy a file from Windows to WSL folder](https://itsfoss.com/content/images/2024/03/transfer-a-file-from-windows-to-wsl.png)
That's it. You have copied the files.
Wrapping Up
Here, you learned about accessing files between Windows and Linux running inside WSL. The ability to access Linux files easily from Windows is super helpful for Windows users. Let me know if you have any questions.