Как открыть папку windows в wsl

Cover image for Access the Windows file system through WSL!

Have you ever wondered, how to access the windows file system through WSL? If the answer is yes you are in the right place!

Microsoft WSL has given us an incredible way to access the windows file system, you have just to navigate through an exact path to do it. Without further due, let’s dive into the topic.

1. Use the cd command in the Linux terminal.

To access the windows files you have to navigate through /mnt/your_windows_path

cd /mnt/c/Users
**OR**
cd /mnt/d/your_folder/your_folder

Enter fullscreen mode

Exit fullscreen mode

Now you have access to every file in the Linux and Windows file systems.

2. Moving files between the two systems through WSL.

If you want to move files between the two operating systems you can simply use the cp or mv commands.
cp — command for copying files
mv — command for moving files
Use of cp command

cp /mnt/c/file.txt /home/username/Documents

Enter fullscreen mode

Exit fullscreen mode

Use of mv command

mv  /mnt/c/file.txt /home/username/Documents

Enter fullscreen mode

Exit fullscreen mode

3. Editing windows files through WSL.

To edit windows files through the Linux terminal using WSL, you have to use any text editor that can be opened in the terminal. One of the most famous text editors is nano. In our example, I am going to use the nano editor.
Type into the terminal nano and the path to the file.

sudo nano /mnt/c/Users/file.txt

Enter fullscreen mode

Exit fullscreen mode

Now you can edit freely files from your terminal.

4. Creating files in windows through WSL.

To create a file in a specific windows directory you have first to navigate to it and then use the touch command to create a file.
touch — a command that creates a file.
!!! The file extension can be anything you want.

cd /mnt/c/Users/Public/Documents/ 
touch filename.txt

Enter fullscreen mode

Exit fullscreen mode

The file is created and can be opened from both systems.

5. Deleting files from the windows file system through WSL.

To delete windows files using WSL, you have to navigate to the directory where the file lives and use the rm command.
rm — a command that deletes files / directories

cd /mnt/c/Users/Public
sudo rm example_file.jpg

Enter fullscreen mode

Exit fullscreen mode

Congratulations you learned 5 vital skills about working with the Linux terminal. 🎺🎺🎺
If you have any questions, comment down, I will answer as soon as possible.

I’m starting to learn how to use the terminal with Ubuntu on WSL (Windows).

Just from the very beginning of the course it says that if you use the ls command it should show you your «home» directories, but mine is something like this:

(base) paloma@DESKTOP-ISCC0ON:~$ ls
Anaconda3-2021.11-Linux-x86_64.sh  anaconda3

(base) paloma@DESKTOP-ISCC0ON:~$

And if I try to change directory something like this happens:

(base) paloma@DESKTOP-ISCC0ON:~$ ls
Anaconda3-2021.11-Linux-x86_64.sh  anaconda3

(base) paloma@DESKTOP-ISCC0ON:~$ cd Documents
-bash: cd: Documents: No such file or directory

(base) paloma@DESKTOP-ISCC0ON:~$

Can somebody tell me why is this happening and what can I do, please? I’m a complete newbie.

NotTheDr01ds's user avatar

NotTheDr01ds

15.8k6 gold badges52 silver badges80 bronze badges

asked Nov 23, 2022 at 11:47

Paloma's user avatar

Everything in @Tooster’s answer is corrected, but let me address your main question a bit more directly:

(base) paloma@DESKTOP-ISCC0ON:~$ cd Documents
-bash: cd: Documents: No such file or directory

Can somebody tell me why is this happening and what can I do, please?

You appear to be wondering why this isn’t taking you to the Documents folder in your Windows home directory.

It’s important to understand that the home directory in Ubuntu/WSL is not the same as your Windows home directory, nor should it be. Your Ubuntu home directory is in a virtual SSD provided by WSL. This virtual SSD provides the Linux compatible filesystem that Ubuntu needs, whereas your Windows drive is formatted as NTFS and won’t have 100% compatibility.

WSL does provide a way to get to the Windows files (including your home directory), as mentioned by @Tooster.

From inside Ubuntu:

cd /mnt/c/Users/<your_Windows_username>
ls

That should show you all the files and directories in your Windows profile (a.k.a. home) folder.

Also perhaps reading as additional background — My answer to Where is WSL located on my computer?.

answered Nov 28, 2022 at 2:29

NotTheDr01ds's user avatar

NotTheDr01dsNotTheDr01ds

15.8k6 gold badges52 silver badges80 bronze badges

First of all try to format code and output from terminals using the fenced code block format.

And now to the meritum.

  • current working directory is the directory you are in. Your home directory (often denoted with ~) is usually located in the /home/<username>/
  • ls — command listing files in the current directory
  • ls [arguments...] — this command lists the files inside directories provided as arguments
  • cd [argument] — change directory command. using it without argument takes you to your home directory
  • / is root directory in linux and an absolute paths start with it
  • . is a current directory and if path starts with ./something or without it something, then current directory is assumed (path is relative to current location)
  • .. is parent directory.

Based on the (base) in thee prompt and on the names of the files above, I’m gonna say that you are using conda environment on your WSL (Windows subsystem for linux). Why are you using it is not my business, but you seem to have skipped a few steps when learning linux and WSL first. Try starting with https://linuxjourney.com/ (especially command line section and filesystem section). Then learn about differences in linux and windows structure.


@EDIT because I only noticed you are using Linux on Windows

Because linux’ and windows’ filesystems are a bit different, when you start linux on windows a virtual filesystem is created for you. To access your windows files from linux you would have to access /mnt/<drive>/<...windows files> (note the / at the beginning — that’s an absolute path)

Linux is structured as a single tree rooted at / and external filesystems are usually mounted at /mnt (read hier(7) for more info). Windows’ filesystem is composed of «drives» — single trees rooted at C:/, D:/ etc., so it’s only natural for both of those systems to have different mechanism for accessing each other’s files.

Read more at https://ling123labs.com/posts/WSL-files-in-Windows-and-vice-versa/

answered Nov 23, 2022 at 12:21

Tooster's user avatar

ToosterTooster

4372 silver badges13 bronze badges

You must log in to answer this question.

Not the answer you’re looking for? Browse other questions tagged

.

I’ve Windows 2010 home ed installed and on top i have installed Ubuntu extension support by Windows.

I’ve started wrting my project there but not sure
how to access directory in Ubuntu from my windows system (host)

any thoughts? Thanks in advance

I’d prefer to not use any external tool for it.

NotTheDr01ds's user avatar

NotTheDr01ds

16.1k5 gold badges45 silver badges70 bronze badges

asked Sep 21, 2019 at 9:28

Amaresh Kumar's user avatar

1

In Windows10 after the may 2019 update, the expected way to access WSL files from windows is via the mounted network drive.

You can access it at \\wsl$\<distro> via explorer, etc. You can even just launch explorer from wsl by running explorer.exe from your WSL shell.

See the dev blog post here for more info: https://devblogs.microsoft.com/commandline/whats-new-for-wsl-in-windows-10-version-1903/


To access the Windows10 filesystem you can just use the mounted filesystem at /mnt/<drive_letter> in WSL

answered Sep 25, 2019 at 2:15

imbuedHope's user avatar

imbuedHopeimbuedHope

5083 silver badges14 bronze badges

figured out lately and as mentioned by @imbuedHope, from wsl command bash shell, you can open current directory by specifying . as follows:

explorer.exe .  //notice the dot

then u could navigate using windows explorer to wherever u want.

answered Sep 22, 2021 at 5:17

Amaresh Kumar's user avatar

Amaresh KumarAmaresh Kumar

5961 gold badge8 silver badges20 bronze badges

In Windows 11 Home, the Linux/Ubuntu folder automatically shows up in Windows Explorer.

In Linux/Ubuntu, the Windows filesystem shows up under /mnt/<mountname>/c. [The «mountname» was a choice provided during the WSL2 installation.] I can access Windows «My Documents» folder through the path: /mnt/arun/c/Users/arun/Documents/.

enter image description here

answered Aug 14, 2022 at 15:44

Arun's user avatar

ArunArun

19.8k10 gold badges51 silver badges60 bronze badges

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

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

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

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

  Ubuntu  | openSUSE Leap  | SUSE Linux Enterprise Server | Debain GNU / Linux | Kali Linux

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

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

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

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

Подробнее в нашей статье: Руководство по установке и запуску — Ubuntu Bash в Windows 10.

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

explorer.exe .

Откроется окно проводника, расположенное внутри вашего дистрибутива 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.

On the Bash on Ubuntu on Windows app, I only have

root@localhost:~# ls -a
    .bash_history  .bashrc  .profile

How do I access all of the Windows folders like Documents, Downloads, etc.?

Hastur's user avatar

Hastur

18.8k9 gold badges53 silver badges96 bronze badges

asked Apr 16, 2016 at 17:33

Sergei Wallace's user avatar

Sergei WallaceSergei Wallace

2,8395 gold badges16 silver badges18 bronze badges

You’ll find the Windows C:\ structure at /mnt/c/ in the Bash environment.

Therefore, my Documents folder is at /mnt/c/Users/Ben/Documents/.

answered Apr 16, 2016 at 17:39

Ben N's user avatar

13

Alternatively,

  1. Hold down Shift while right-clicking in your desired Windows directory
  2. Select «Open PowerShell window here«

PowerShell Context Menu

  1. Once you’re in PowerShell, type bash

You’ll be able to use any Bash commands directly to operate on the files and folders in that Windows directory. By using this method, you don’t have to manually cd into your directories especially when you’ve a deep-rooted directory to access.


Update as of Windows 10 1809:

Above still works, but there’s an easier method now.

  1. Hold down Shift while right-clicking in your desired Windows directory
  2. Select «Open Linux shell here«

answered Oct 11, 2017 at 5:14

Keith OYS's user avatar

Keith OYSKeith OYS

4814 silver badges6 bronze badges

8

You must log in to answer this question.

Not the answer you’re looking for? Browse other questions tagged

.

  • Как открыть папку мой компьютер в windows 10
  • Как открыть параметры в windows 10 горячие клавиши
  • Как открыть папку windows task
  • Как открыть папку мои документы в windows 10
  • Как открыть папку temp windows 10