16

According to this answer global/system config files are generally stored under /etc in linux. Is this also the case for WSL? If so where is the /etc equivalent directory located, as I was unable to find it in the WSL installation directory shown below:

C:\Users\user\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu18.04onWindows_79rhkp1fndgsc

Read the warning by @josh3736 in the answers below and don't make the mistake I made. Look at this to edit WSL files correctly.

18

I found my etc folder in:

C:\Users\USER\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState\rootfs\etc

Note: I'm using WSL1 so as to be able to use VMware. WSL2 uses Hyper-V which is incompatible with other virtualization hypervisors. (Edit: This is no longer true.)

However, this is changing now and in the near future. Recently both VirtualBox and VMware have released versions that support Hyper-V and WSL2. You can learn more about it for VirtualBox and VMware. The VMware solution requires the soon to be released Windows 10 Build 20H1, while VirtualBox is possibly usable now.

This next version of Windows is also advertised as allowing greater integration between Windows and WSL, perhaps even solving the problem of concurrent updates of the same files from both subsystems.

6
  • 1
    This does not work with WSL 2. There, the whole disk is located in a single file. – dan1st May 3 '20 at 15:44
  • 1
    @dan1st: WSL2 at the moment is a bit of a mess in that respect. The Windows/Linux interface supposedly will be improved in the next major Windows version. You can read all about the problem in bug report #4260 WSL2: can't access linux file system from windows. – harrymc May 3 '20 at 17:03
  • I use WSL2 since about half a year and had no problems. – dan1st May 3 '20 at 17:49
  • @dan1st: Some have and some haven't and this can change very suddenly. Read the bug report. – harrymc May 3 '20 at 18:23
  • 1
    Please edit in at least a note that these files should not be edited directly via those paths. – Bob May 4 '20 at 1:08
31

Warning: do not edit WSL files on disk from Windows.

The files stored on disk in %LocalAppData%\Packages use special NTFS features to implement POSIX functionality/metadata (eg Linux permissions). Using standard Windows tools/apps to edit these files will corrupt your Linux environment.

Instead, WSL provides a mount that allows you to safely access and edit files inside your Linux environment. It is available under \\wsl$\.

See Do Not Change Linux Files Using Windows Apps and Tools

1
  • If we can't edit WSL files directly from a host NTFS volume why isn't WSL just using a VHD/VHDX? Seems weird to expose the files if we can't do anything with them... – Dai May 4 '20 at 1:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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