Как в wsl перейти в папку windows
Перейти к содержимому

Как в wsl перейти в папку windows

  • автор:

Доступ к файлам 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 $ \ <running_distro_name> \.

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

Доступ к файлам 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.

How to change directory within Ubuntu WSL in Windows format?

I have installed Cygwin on Windows. To change dir in Cygwin could be done in 2 ways:

In Unix format:

In Windows format (surrounded by double quotes):

Is there a way to change dir in Ubuntu WSL like can be done on Cygwin, using Windows format?

I get this error when trying on Ubuntu:

4 Answers 4

No. In order to access Windows files from WSL you need to visualize an Ubuntu VM that has mounted NTFS drives, so access needs to be using /mnt/c/. or /mnt/d/. etc.

You need to use forward slashes as shown, since backward slashes ( \ ) will be interpreted as escape characters within WSL.

WSL stores your Windows drives in the /mnt folder, with the name of the drive as a subfolder. For example your C:\ drive will be present at /mnt/c/ for you to use.

Where is the C drive in the WSL? [duplicate]

Whenever I try to login to bash using the Windows Subsystem for Linux, I try to cd into C:\Users\ , but all I get is directory not found.

Where is the C drive for the Windows Linux subsystem? Is it isolated?

3 Answers 3

The WSL has access to your PC’s file system through /mnt/<drive letter>/ directories (or mount points). For example, your C:\ and D:\ root directories in Windows would be available through /mnt/c/ and /mnt/d/ respectively in the WSL

Just cd into the /mnt folder and you’ll be fine

AJM's user avatar

/mnt/c or /mnt/<drive letter>/

you’ll find your local drives mounted under the /mnt folder.
For example, your C: drive is mounted under /mnt/c [msdn]

The Linux filesystem is a unique tree (there are no C:\ , D:\ . ).
The root of this tree is / (note / not \ ).

All the units – partitions, pen drives, removable disks, CD, DVD – will be available when mounted on a point of this tree. Then you will see them as normal directories.

The usual place where the additional partitions are mounted is the /mnt directory.
This works under the Windows Linux Subsystem too.

Note: Under Linux, you’ve got to use the slash ( / ) instead of the backslash ( \ ) to separate the directories in a path. And usually a Linux filesystem is case sensitive ( mydir and Mydir are two different things).

AJM's user avatar

Since the days of Windows NT, there has been another way to access drives. Instead of using a letter, you can bind a drive to a folder in the filesystem. Microsoft calls these mounted folders. As far as the end user is concerned, they work just like normal folders do: they happen to reside on another drive, but under most circumstances you don’t notice. This can be useful in a number of scenarios, but it turns out to be critical if you happen to have so many drives mounted that you run out of drive letters, but need to add even more: mounted folders are how you can do that.

In Linux (and Unix, which inspired it), all drives work this way. There is only one filesystem, which starts at the empty path / (and is typically bound to a drive), and then you mount your other drives (or, sometimes, other things) using directories inside / . These are called mount points in Unix terminology (which Linux inherited). For example, user home directories are often in /home/ username, but it’s common to make /home a mount point for another drive entirely. That way if the drive you boot from fails for some reason, your home directories aren’t affected. The users just go to /home/ username like they always do; unless they’re responsible for maintaining the machine, they don’t have to know or care what drive their home directories are on.

The WSL tries to imitate Linux, so it does this too. To bridge the gap, it mounts your Windows drives in the folder ‘/mnt/’, using the drive letter as the directory name. Your C: drive, for example, can also be found at /mnt/c , while your D: drive is at /mnt/d .

Как в wsl перейти в папку windows

Welcome to the LING123 Lab Sessions! In this very first lab session, we’ll begin with looking at some basic concepts for computational linguistics and processing language data. After that, we.

Solutions to the exercises from Lab Session 01

Try to solve the lab exercises by yourself before you view the solutions! You can find the exercises to Lab Session 01 here. Lecture notes Disagree with my answers, or have something to add.

Software installations for LING123

LING123: Language and Computers contains a significant amount of shell-scripting in Linux. If you are using MacOS (or a Linux OS for that matter), you already have access to a compatible shell. J.

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *