WSL file access right problem

Stanislas JEANGEY 0 Reputation points
2023-10-30T06:17:48.0433333+00:00

Hello,

I recently installed Windows Server Datacenter 2022, installed the Docker-Desktop.exe application and then installed Ubuntu using the following command: wsl --install Ubuntu

I then launched Ubuntu and configured the first boot, then added my current user and root to the www-data group.

I did this to be able to access, from Windows Explorer, the WSL files located at \wsl.localhost.

I then set up docker-desktop to use the Ubuntu distribution.

The problem is that at startup I have access to the files, but as soon as I try to perform an operation on the files, I lose access rights.

I've also added a file in the following directory: /etc/wsl.conf which contains the following:

# Enable extra metadata options by default
[automount]
enabled = true
root = /windir/
options = "metadata,umask=22,fmask=11"
mountFsTab = false
[network]
generateHosts = true
generateResolvConf = true

How can I keep access rights to files?

Windows for business | Windows Server | User experience | Other
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Henry Mai 7,010 Reputation points Independent Advisor
    2025-09-23T14:59:41.35+00:00

    Hello Stanislas, I am Henry and I want to share my insight about your issue.

    The problem is that when you edit files from Windows Explorer, the Linux permissions are reset. Your /etc/wsl.conf settings are for a different purpose and won't fix this. The solution is to run these commands inside your Ubuntu terminal. They force your project folder to automatically assign the correct group (www-data) to all new files and folders, even when created from Windows.

    The Fix:

    Run these three commands in your Ubuntu terminal. Replace /path/to/your/project with your actual project path.

    1. Set ownership to your user and the www-data group
    • sudo chown -R $USER:www-data /path/to/your/project
    1. Give the group write permissions
    • sudo chmod -R g+w /path/to/your/project
    1. Make all new files inherit the 'www-data' group
    • sudo chmod g+s /path/to/your/project

    Online References for Details:

    Hope this clears things up

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.