The Windows Subsystem for Linux is very helpful when it comes to making Windows files available for use under /mnt/c, including synthesizing permissions (for those files which don’t have their own Linux-specific metadata) to make them useful under your WSL distro.
But this can occasionally cause issues, since the default makes files on your Windows filesystem look just like files your Linux user owns, and they don’t always behave that way - and this can lead you down some long detours in figuring out the problem if you don’t remember which directory you’re in (oops), made rather easier if you have various symlinks to bits of the Windows filesystem from places inside your Linux filesystem, thus depriving you of the obvious clue given by the /mnt/c in the cwd part of your prompt (double oops).
Conveniently, though, WSL also gives us the tools to make those files stand out. Here’s how I do it:
First, I create a new system user and group (called “windows”) to act as the owner of DrvFs files, thus:
sudo groupadd -r windows
sudo useradd -r -c "Windows filesystem owner" -g windows -d /mnt/c -N -s /usr/sbin/nologin windows
Having done this, the next thing to do is make sure your default user is a member of the group you created, so that you can access files on your Windows host:
sudo usermod -a -G windows avatar
(Using your own username in place of avatar, of course.)
And finally, modify the filesystem options for the automounted DrvFs filesystem in your /etc/wsl.conf. (Should you mount other DrvFs filesystems manually, you’ll want to make the same changes there.) Mine is as follows:
[automount]
enabled = true
options = "uid=996,gid=996,metadata,umask=002,fmask=002"
The important parts here are the uid and gid entries (use the uid and gid of the user and group you created in the first step; it was 996 on my system but might not be on yours) which change the owner synthesized for the Windows files by DrvFs, and the fmask entry. Setting the latter to 002 makes the Windows files read/write/executable by the windows group, not just by the user, and thus ensures you - per the second step - have full access to them.
Then shut down and restart your WSL session, and when you ls -la /mnt/c, you should see directory entries like this:
drwxrwxr-x 1 windows windows 4.0K Mar 15 2021 RunInGenie/
-rwxrwxr-x 1 windows windows 181K Jan 9 2021 SigQuotes.txt*
drwxrwxr-x 1 windows windows 4.0K Jan 31 2021 vagrant-test/
-rwxrwxr-x 1 windows windows 3.8K Dec 19 2020 vault-intermediate-ca.pfx*
-rw-rw---- 1 avatar avatar 659 Feb 17 2021 vault-key.gpg
Which makes it very clear that these are files from your Windows filesystem.
(That last one? I used the metadata option to apply Linux ownership and permissions to it under DrvFs - and so it stands out clearly against the regular, untouched Windows files. Handy, ne?)