Where are config files located in WSL?
Solution 1
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.
Solution 2
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
Related videos on Youtube
Comments
-
MShakeG over 1 year
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.
-
dan1st about 4 yearsThis does not work with WSL 2. There, the whole disk is located in a single file.
-
harrymc about 4 years@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.
-
dan1st about 4 yearsI use WSL2 since about half a year and had no problems.
-
harrymc about 4 years@dan1st: Some have and some haven't and this can change very suddenly. Read the bug report.
-
tvdo about 4 yearsPlease edit in at least a note that these files should not be edited directly via those paths.
-
Khalid about 4 yearsIf 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...
-
harrymc about 4 years@Bob: That depends on how the updates are done. Many of these files are intended to be updated by the user. The next version of Windows supposedly will allow dual updates of the same files from both Windows and Linux without problem.