View linux files in windows

How to access linux/Ubuntu files from Windows 10 WSL?

This question answers how to access Windows files from Ubuntu Bash, but how can I do the opposite? Specifically, I need to access my SSH key from Windows which is located at /home/mark/.ssh/id_rsa under Bash.

(I have suggested to close phuclv’s linked question as dupe in reverse-chronological order as this question is both more general and has far better and more up-to-date answers.)

Perhaps it’s obvious to some, but in reality you really don’t need to have Win access to the linux files. As folks clearly state below, doing so is Dangerous. Instead, you can do most everything you need from the bash shell. For example, to copy your id_rsa file to you windows section, you can do that from bash via /mnt/c/user/ yadda yadda. I made a symbolic link to my Win Desktop in my Bash home and I can move, delete, etc from within bash.

@mikemtnbikes Copying it won’t keep it in sync. A symbolic link between windows and linux? Does that even work? If it does, that sounds equally dangerous. I only intended to read the files, but regardless, we have \\wsl$ now which is perfectly safe.

@mpen my limited understanding is that you can mess things up using Windows Explorer (or any non-ubuntu shell program) to access WSL, but not the other way around (That is, I believe using ubuntu to access WSL files or std win files shoudl be fine since the shell should be WSL ‘aware’). Thus, I expect you should be able to make a symbolic link within the shell from the WSL to non-WSL directories and vice versa. (Please note the caveats and let me know if you try making links and, if so, what the outcome is.)

14 Answers 14

PM for Windows Command-Line here:

Updated October 2019: Updating the response below to reflect the newly added ability to directly access distros’ Linux files via the newly integrated P9 server in Win10 1903 (and later).

IMPORTANT: Spelunking through the Windows filesystem to access Linux files has and will continue to be unsupported and STRONGLY recommended against! To understand why, please read this post

So how does one access Linux files using Windows tools (e.g. notepad, VS/VScode, etc.)? Previously, you couldn’t, but starting in Windows 10 1903 we (finally!) expose your distros’ filesystems to Windows via a P9 fileserver. We’ve also published an in-depth video discussing how this works! You can also read a summary of this new feature in this blog post

Источник

How to Access Linux Files from Windows 10/11

How to access Linux files from windows

While Windows is cool, some folks want to try out Linux to experience the best of both worlds. In the end, they end up dual-booting their PC, where they can have both Windows and Linux OSes existing on the same or different drives. Picture this, you’re currently on Windows and realize that you left an important file on Linux during your last Linux session. Now, you are too lazy to boot into Linux and get the file back, so how do you get it back while remaining on Windows? In this article, let’s look at how to access Linux files from Windows 10/11.

Читайте также:  Google chrome настройка linux

Usually, you could access Windows files from Linux because Linux supports NTFS, a proprietary file system from Microsoft. However, Windows doesn’t support Ext4 or any file system used by Linux. So here are some ways to do it.

Access Linux Files from Windows using Linux Reader

Linux Reader is a freemium app that lets you access your Linux files from Windows in an easy way. All you need to do is download the app and launch it. It will list all the disks and partitions that are currently sitting on your PC. You can then select the one which has Linux installed on it and start accessing your Linux files. Although, one major drawback of Linux Reader is the free version doesn’t allow you to save files to your Windows PC. The pro version costs almost $36 and unlocks a few other features.

Linux reader website download

2. Launch the app and click on your Linux disk.

DiskInternals Linux Reader

3. Go to the location of the file you want to save to Windows, right-click on the file, and then click “Save” from the options.

Save file in Linux reader

4. Select the location where you want to save the file and click Next. The file will be saved in the desired location.

Save file in location windows

Linux Reader is a read-only app; hence, it won’t damage your Linux partitions.

Access Linux Files from Windows Using Ext2read

Ext2read is another great tool for accessing Linux files from Windows. It’s a simple application that supports Linux’s Ext partitions and displays the files so that you could save them on your Windows PC. Here’s how to use Ext2read.

1. Download Ext2read using the link right here.

EXT2Read

2. Once downloaded, extract the zip file to your desired location.

Extract EXT2Read

3. Right-click on the executable file and select “Run as Administrator” from the context menu.

Run EXT2Read as administrator

4. The app should now display all your Linux files. Sadly, our Fedora installation is Btrfs and Ext2read is a pretty old app, so it wasn’t able to detect our Linux drive.

Ext2Explore Screenshot

5. But if you have a compatible partition, it should work just fine for you. Navigate to the file you want to fetch and click Save in the options pane.

Access Linux Files from Windows Using WSL

Windows Subsystem for Linux has made things better for developers who like working on Linux. If you have WSL installed, and as long as the disk you’re trying to access is not a part of the same drive as your Windows installation, you can access and transfer files from the Linux partition to Windows. Here’s how to do it.

Step 1: Install WSL

  1. On your Windows PC, press the Windows key once and type “windows features.” After that, click on “Turn Windows features on or off”.

How to Access Linux Files from Windows 10/11

If you already have it installed, skip to the fourth step.

2. Next, scroll down and enable “Windows Subsystem for Linux” here.

Читайте также:  Linux change time zone

How to Access Linux Files from Windows 10/11

3. Now, restart your computer to reflect the changes.

Step 2: Download & Install Debian

1. Go to the Microsoft Store, search for Debian, and install the first result.

Debian on the Windows Store

2. Once downloaded, open the terminal (Cmd) and run the command:

3. WSL should then prompt you to set a “UNIX username” and a “UNIX password.” Once done, WSL is all set and ready to go.

How-to-Enable-the-Linux-Bash-She

Step 3: Mount Linux Drive

1. Shut down WSL, open the Command Prompt as an administrator, and enter the following command to list all the available disks.

GET-CimInstance -query "SELECT * from Win32_DiskDrive"

Command to list all available disks in Windows

2. Make note of the drive where Linux is installed and mount that drive using the following command.

wsl --mount \\.\PHYSICALDRIVE2 ## where '2' is the drive number and may differ in your PC

Mounting the disks and partitions

3. If you have an EFI (\boot) partition in Linux, the above command doesn’t work. In this case, try mounting the Linux partition using the following command:

wsl --mount \\.\PHYSICALDRIVE2 --partition 2 ## Where 2 is the partition where the /root and /home partitions of our Linux install reside

Step 4: Access Linux Files using GUI or Terminal

1. Once installed, you can now access the files and folders on Linux. Try not to make any changes in the Linux partitions.

2. If you don’t like moving folders using the terminal, you can install Nautilus, GNOME’s default Files app, and move files using the same. To install Nautilus, use the following command.

sudo apt install nautilus

3. Once installed, launch it, go to other locations > Computer > mnt > WSL > PHYSICALDRIVE2 to access all the files.

Источник

Доступ к файлам WSL Linux с помощью Проводника Windows 10

Windows 10 версии 1903 содержит ряд интересных изменений и улучшений, внесенных в функцию WSL. К ним относятся дополнительные дистрибутивы в Магазине, возможность просматривать файлы WSL в Проводнике и многое другое.

Возможность запуска Linux в Windows 10 обеспечивается функцией WSL. WSL это — Windows Subsystem for Linux, которая изначально была ограничена только Ubuntu. Современные версии WSL позволяют устанавливать и запускать несколько дистрибутивов Linux из Microsoft Store.

После включения WSL вы можете устанавливать различные версии Linux из Магазина, используя следующие ссылки:

Ссылки на дистрибутивы в магазине microsoft:

В Windows 10 версии 1903 вы можете легко получить доступ ко всем файлам в ваших дистрибутивах Linux с помощью проводника Windows. На момент написания статьи эта функция реализована в сборке Windows 10 18836. Она находится на пути к ветви 19h1, поэтому мы увидим ее в следующей сборке. Вот как это можно сделать.

Чтобы получить доступ к файлам WSL Linux из проводника Windows 10 , выполните следующие действия.

Шаг 1: Включить функцию WSL (Подситема Windows для Linux)

Шаг 2: Установите какой-нибудь дистрибутив, например Ubuntu, и запустите его.

Шаг 3: Находясь в каталоге Linux FS, введите^

Откроется окно проводника, расположенное внутри вашего дистрибутива Linux.

Доступ к файлам Linux в Windows 10

Теперь вы можете получить доступ к любым файлам Linux, так же, как и к любому другому файлу через проводник. Это включает в себя такие операции, как: перетаскивание файлов в другие места, копирование и вставка и даже использование пользовательских записей контекстного меню, добавленных Notepad ++, VSCode или другим программным обеспечением.

Проводник показывает файлы дистрибутива как виртуальный сетевой ресурс по пути \\ wsl $ \ \.

Команда WSL активно исследует способы улучшения обнаруживаемости файлов Linux внутри Проводника. Ход их работы уже можно увидеть в Windows 10 Build 18836, которая показывает файловую систему WSL / Linux в File Explorer.

Читайте также:  Postgres linux default password

Доступ к файлам Linux в командной строке

В дополнение к Проводнику вы можете использовать классическую командную строку и инструменты PowerShell для доступа к файлам Linux. Точно так же вам нужно перейти к \\wsl$\\, где — это имя работающего дистрибутива.

WSL в PowerShell

Известные вопросы

Это новая функция, и некоторые ее части могут не работать идеально. Вот некоторые известные проблемы, о которых мы хотим сообщить вам при использовании этой функции:

На данный момент файлы дистрибутивов будут доступны только из Windows, когда дистрибутив работает. Разработчик собирается добавить поддержку не работающих дистрибутивов в будущем обновлении.

Поскольку файловый сервер 9P работает внутри каждого дистрибутива, он доступен только тогда, когда этот дистрибутив работает. Команда ищет способы решить эту проблему.

Доступ к файлам Linux рассматривается так же, как и доступ к сетевому ресурсу, и все правила доступа к сетевым ресурсам будут по-прежнему применяться,

  • Например: при использовании CMD cd \\wsl$\Ubuntu\home не будет работать (поскольку CMD не поддерживает пути UNC, так как текущие каталоги), однако будет работать copy \\wsl$\Ubuntu\home\somefile.txt C:\dev\
  • Старые правила по-прежнему применяются, вы не должны получать доступ к файлам Linux внутри папки AppData!
  • Если вы пытаетесь получить доступ к своим файлам Linux через папку AppData, вы используете обход сервера 9P, что означает, что у вас не будет доступа к файлам Linux, и вы можете повредить ваш дистрибутив Linux.

Примечание: Сервер 9P — это сервер, который содержит протоколы, поддерживающие метаданные Linux, включая разрешения. Демон инициализации WSL теперь включает сервер 9P. Существует служба Windows и драйвер, который действует как клиент и взаимодействует с сервером 9P (который работает внутри экземпляра WSL). Клиент и сервер обмениваются данными через сокеты AF_UNIX, поскольку WSL позволяет взаимодействовать между приложением Windows и приложением Linux, используя AF_UNIX.

Источник

Access Linux filesystems in Windows and WSL 2

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

wmic diskdrive list brief 

terminal with wsl text

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

Accessing an EXT4 partition 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.

Источник

Оцените статью
Adblock
detector