87

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?

  • For user folder type in, cd /mnt/c/Users ...to access desktop type in, cd /mnt/c/Users/my-name/Desktop ...case sensitive – kar Aug 4 '16 at 1:35
102

Taken from this website:

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

22

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

  • how do you access DVD from WSL? I only see /mnt/c in there – santiago arizti Sep 24 '19 at 21:12
  • 1
    But this is another question ;-) (@santiagoarizti). BTW once mounted it should be in /mnt/d or similar. (Under pure Linux it may be under /media/YourUsername/TheLabelNameOfCd or similar). If you need to mount it before create a directory e.g. sudo mkdir /mnt/MyDVD then mount it with something like sudo mount -t drvfs D: /mnt/MyDVD or similar commands... – Hastur Sep 25 '19 at 12:18
7

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.

Not the answer you're looking for? Browse other questions tagged or ask your own question.