- How do I access the WSL Linux file system from Windows?
- 6 Answers 6
- Copy Files Between Windows and Linux Using Command Line
- Copy File from Windows To Linux
- Copy File From Linux To Windows
- Access Linux filesystems in Windows and WSL 2
- Getting started
- Accessing these files with File Explorer
- Limitations
- Give us your feedback!
- Copy file from Windows shared folder to Unix
- 3 Answers 3
- 2 Ways to Copy Files from Windows 10 to Windows Sub-System for Linux
- Distribution Package of Windows Sub-System for Linux
- Copy Files
- Method 1 – Manual Copy-Paste
- Method 2 – Windows System Drive as a Mount point
- Video Tutorial
- My New Book : PowerShell Scripting Guide to Python
How do I access the WSL Linux file system from Windows?
I found that static files served from a Rails application running in /home/pupeno/projectx take more or less half as much time than the ones served from /mnt/c/Users/pupeno/projectx . It’s almost acceptable. I tried webrick and puma (as well as passenger and unicorn, which don’t work yet).
So, if I’m going to host my source code in /home/pupeno , how do I access from Windows applications such as RubyMine?
For the record, this is the application being served from the Windows file system:
and this is the Linux file system:
6 Answers 6
PM for Windows Command-Line here:
However, as of Windows 10 build 1903 (March 2019), we (finally!) exposed your distros’ filesystems to Windows!
Look forward to hearing how you get on with this feature. If you find any problems, please file issues on the WSL GitHub repo here: https://github.com/microsoft/wsl.
WSL mounts Windows partitions under /mnt . For example, you can modify files in c:\work on the mounted Windows filesystem by referencing them as /mnt/c/work .
Windows apps (cmd, file manager, etc), can access files in WSL in read-only mode by prepending with %LocalAppData%\lxss . Copying a file from the Windows filesystem to the WSL directories renders it unreadable, with a cryptic general I/O error . Files created in %LocalAppData%\lxss from Windows are not visible to WSL. Files created from WSL can be modified in Windows, and the modified file can subsequently be accessed by WSL.
Copy Files Between Windows and Linux Using Command Line
It is not always that you will need to copy a file from Windows to Linux or vice versa. But at times when you are automating things or trying to achieve some copy functionality using a script, it is good to have a utility to do that. Here is where pscp comes into play. Using pscp you can copy the file to/from windows and Linux. In this guide, I will go through the steps of doing the same.
Copy File from Windows To Linux
1. Download pscp.exe from here
2. copy the pscp.exe executable to the system32 directory of your windows machine. This folder normally exists in C:\Windows\System32 path.
3. Open PowerShell and use the following command to verify if pscp is accessible from the path.
4. Use the following format to copy the file to the Linux box.
- -pw for the password.
- replace password with the Linux user password.
- C:\Users\Admin\Desktop\test.txt represents the path of the file that has to be copied to the Linux system.
- 192.168.33.10 is the IP of the Linux server.
- /home/vagrant is the user-accessible path in the Linux system to copy the file.
If you are using private keys for authentications, you can use -i flag instead of -pw followed by the path to the .ppk file. If your key file is in pem format, you can use the puttygen command to convert it to ppk.
Info: Learn Linux & Windows administration from Pluralsight with its 10 days free account
For key-based authentication, the command looks like below.
Copy File From Linux To Windows
You can use pscp to copy files from Linux to windows. use the following command format for the same.
The above command will copy the file in Linux from the specified path to the Windows desktop.
Access Linux filesystems in Windows and WSL 2
September 10th, 2020
Starting with Windows Insiders preview build 20211, WSL 2 will be offering a new feature: wsl —mount . This new parameter allows a physical disk to be attached and mounted inside WSL 2, which enables you to access filesystems that aren’t natively supported by Windows (such as ext4).
So, if you’re dual booting with Windows & Linux using different disks, you can now access your Linux files from Windows!
Getting started
To mount a disk, open a PowerShell window with administrator privileges and run:
To list the available disks in Windows, run:
To unmount and detach the disk from WSL 2, run
The disks paths are available under the ‘DeviceID’ columns. Usually under the \\.\\\.\PHYSICALDRIVE* format. Below is an example of mounting a specific partition of a given hard disk into WSL and browsing its files.
Accessing these files with File Explorer
Once mounted, it’s also possible to access these disks through the Windows explorer by navigating to \wsl$ and then to the mount folder.
Limitations
By default, wsl —mount attempts to mount the disk as ext4. To specify a filesystem, or for more advanced scenarios, check out Mount a disk in WSL 2.
Also please note that this feature comes with the limitation that only physical disks can be attached to WSL 2. At this time, it’s not possible to attach a single partition. More details on the limitations here.
Give us your feedback!
If you run into any issues, or have feedback for our team please file an issue on our Github , and if you have general questions about WSL you can find all of our team members that are on Twitter on this twitter list.
Copy file from Windows shared folder to Unix
I am totally new to Unix. I am writting a script which will copy files from a Windows shared folder to Unix.
In Windows, when I type \\Servername.com\testfolder in Run command I am able to see testfolder . The directory testfolder is a shared folder through the whole network.
Now I want to copy some files from that testfolder to a Unix machine. Which command should I use? I know the IP Address of server but I don’t know the username.
3 Answers 3
From your UNIX server you need to mount the Windows share using the procedure laid out in this link.
Basically you create a directory on your UNIX machine that is called the mount point. You then use the mount command to mount the Windows share on that mount point. Then when you go to the directory that you have created you see the files that are in the Windows share.
With smbclient installed on the *nix machine, you don’t need to mount the Windows share at all. For example, to retrieve C:\Directory\file.txt and copy it to /tmp on your Linux computer do this:
See https://superuser.com/a/562728/48742 for details. This was discussed over there.
If you can see \Servername.com\testfolder in Windows machine, then you can use your own username and password.
On a linux machine, you can use
sudo mount -t cifs -o username=YourWindowsLogin,password=YourWindowsPassword //Servername.com/testfolder /mnt/testfolder
/mnt/testfolder must exist beforehand.
Then you can copy file from /mnt/testfolder .
Use sudo umount /mnt/testfolder to unmount the folder.
2 Ways to Copy Files from Windows 10 to Windows Sub-System for Linux
Today we are going to discuss about how to copy file from your Windows 10 machine to Windows Sub-System for Linux.
Distribution Package of Windows Sub-System for Linux
First thing first, before you can even begin you have to understand where all the Linux files are placed in your Windows 10 machine. To avoid any accidental tampering Microsoft stores all you Linux files under the following hidden folder:
Here you can find your Linux distribution packages (distro) , double-click on the folder for your distribution, following is name of distribution package and folder name mapping:
Distribution Package | Folder Name |
---|---|
Ubuntu | CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc |
openSUSE Leap 42 | 46932SUSE.openSUSELeap42.2_022rs5jcyhyac |
SUSE Linux Enterprise Server 12 | 46932SUSE.SUSELinuxEnterpriseServer12SP2_022rs5jcyhyac |
For Ubuntu which I’m using, I’ll look for CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc and then navigate to folder navigate to .\LocalState\rootfs\ folder. This is the root file share where all you files are placed
Copy Files
Method 1 – Manual Copy-Paste
You can simply move or copy-paste files inside one of these Linux directories,
but the files won’t appear in you Windows Sub-system for Linux Bash Shell until you restart it.
Method 2 – Windows System Drive as a Mount point
Windows Sub-System for Linux provides you access to the Windows 10 system drive by mounting the C:\ . On Linux if you go to you root directory and list all directories, then you will notice a /mnt/c/ which is Windows 10 C:\ mounted on Linux
Now simply use copy command ( cp ) to copy files over to your Linux Subsystem.
Video Tutorial
If you like this article read more similar articles under ‘N – Ways to’ category
My New Book : PowerShell Scripting Guide to Python
This PowerShell Scripting guide to Python is designed to make readers familiar with syntax, semantics and core concepts of Python language, in an approach that readers can totally relate with the concepts of PowerShell already in their arsenal, to learn Python fast and effectively, such that it sticks with readers for longer time.
“Use what you know to learn what you don’t. ” also known as Associative learning.
Book follows a comparative method to jump start readers journey in Python, but who is the target audience? and who should read this book –
- Any System Administrator who want to step into Development or Programming roles, and even if you don’t want to be a developer, knowledge of another scripting language will make your skill set more robust.
- Python Developers who want to learn PowerShell scripting and understand its ease of user and importance to manage any platform.
Python is one of the top programming languages and in fast changing IT scenarios to DevOps and Cloudto the future – Data Science, Artificial Intelligence (AI) and Machine Learning Python is a must know.
But this PowerShell Scripting guide to Python would be very helpful for you if you already have some knowledge of PowerShell
NOTE! This is a Leanpub “Agile-published” book. That means the book is currently unfinished and in-progress. As I continue to complete the chapters, we will re-publish the book with the new and updated content. Readers will receive an email once a new version is published!
While the book is in progress, please review it and send any feedback or error corrections at [email protected]
Follow @SinghPrateik