192

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
  • 18,764
  • 9
  • 52
  • 95
Sergei Wallace
  • 2,829
  • 5
  • 16
  • 18

2 Answers2

314

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/.

Ben N
  • 40,045
  • 17
  • 140
  • 181
  • why does mnt not show up with ls -a? – Sergei Wallace Apr 16 '16 at 17:52
  • 5
    You were in the `~` directory, your home in the Bash environment, which is not the root (`/`). If you had done `cd /` first, you would have seen `mnt`. – Ben N Apr 16 '16 at 18:01
  • When it comes to building scripts, the 2nd sentence doesn't necessarily follow from the first. Windows lets you move your documents folder around all over the place. It would be nice to be able to read that info from the Windows registry or similar while using bash. – Joel Coehoorn Oct 06 '16 at 23:46
  • 1
    how can I access stuff outside C? for instance, I connected a phone via MTP and its files shows up at a path "This PC\PhoneName" – Michael Dec 20 '16 at 16:47
  • 1
    @Michael Unfortunately, MTP devices are very unlike normal file systems. They [aren't even accessible from a normal command prompt](http://superuser.com/a/377008/380318), so I don't know of a way to access them from BoUoW. – Ben N Dec 20 '16 at 17:05
  • Thanks Ben! Noticed a comment about using a WebDAV server on the device, and that seems to work! – Michael Dec 20 '16 at 17:10
  • Well I'm going to have to retract WebDAV as a valid solution... in transferring 1005 image files across WebDAV, 925 were corrupted (as verified by md5 on the original and copied file)! – Michael Dec 24 '16 at 18:19
  • so just make a link to drive in your home folder: `ln -s /mnt/c/ .` – Yar Feb 23 '17 at 01:21
  • I am getting `No such file or directory` error. – Iqbal Jul 12 '17 at 10:08
  • @Iqbal Note that Linux is case-sensitive, so make sure to type uppercase letters when necessary. If that doesn't help, could you `cd` into the directories one at a time and tell me which is the problem? – Ben N Jul 12 '17 at 14:00
  • hey, any idea why would /mnt/c not exist on my system? (ls in /mnt returns nothing) – TanZor Aug 05 '20 at 08:44
  • @TanZor Occasionally after rebooting, the WSL mount points go away for some reason. You can try to [manually remount the C drive](https://github.com/microsoft/WSL/issues/1864#issuecomment-392350563). [This other thread](https://github.com/microsoft/WSL/issues/4122) has some other things you can try. – Ben N Aug 05 '20 at 14:43
  • Thanks @BenN, I now realized that this question was about WSL whereas I'm struggling with a dual-boot setting. – TanZor Aug 06 '20 at 06:58
37

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"
Keith OYS
  • 481
  • 4
  • 6
  • 1
    In my right-clicked context menu, I don't see the item for Open PowerShell window here – Yu Shen Apr 24 '18 at 01:47
  • 1
    yep, same here..... – Yaroslav Dukal May 13 '18 at 03:33
  • @YuShen Do ensure that you've the latest Windows 10 update installed. For instance, the current version is 1803 and it has the option. I realize some machines which weren't updated still has CMD as their default and hence does not have this option in the context menu. – Keith OYS May 27 '18 at 12:55
  • It doesn't work, the bash commands opens in default ubuntu user directory, not curret windows directory – mxdsp Oct 22 '18 at 16:44
  • @mxdsp What were your steps and your Windows version? Please detail it out for me so I could help you further. If you did it correctly, it would bring you into your current windows directory. Ain't wise downvoting just because it doesn't work for you. – Keith OYS Oct 23 '18 at 17:21
  • You can change the default from CMD to Powershell and back again by following these steps. Start > Settings > Personalization > Taskbar > Replace Command Prompt with Windows PowerShell in the menu when I right-click the start button or press Windows key+X – Nathaniel Sep 13 '19 at 03:40
  • The updated answer for Windows 10 >=1809 is exactly what I was looking for. **Note** to others that you must right-click on the folder you're wanting to "cd" to in Ubuntu - you can't navigate inside that folder and right click in the file pane or right click in the address bar. – Luke Aug 29 '20 at 12:15
  • It worked, it's much more easy to use Linux Bash with Powershell. Thanks ! – Enrique Benitez Mar 02 '21 at 15:19