在Windows 10的Ubuntu应用中获取父系统文件读写权限的方法
Hey there! Let's tackle this permission issue you're facing when accessing Windows files from your Microsoft Store-installed Ubuntu (WSL). The root cause lies in how WSL maps Windows file system permissions to Linux-style permissions, but we've got two reliable fixes to sort this out:
方法1:修改WSL的全局挂载权限配置(推荐)
This is the cleanest way to set consistent permissions for all Windows files accessed via WSL, instead of adjusting each file individually.
- First, open your Ubuntu terminal and create/edit the WSL config file:
sudo nano /etc/wsl.conf - Paste the following content into the file. The
umaskvalue controls default permissions—0022gives you read/write/execute access, while others get read/execute (a safe, standard setup):
If you need full read/write/execute access for everyone (not recommended for security, but useful in some cases), replace[automount] enabled = true options = "metadata,umask=0022,fmask=0133" mountFsTab = falseumask=0022,fmask=0133withumask=0000. - Save the file (press
Ctrl+O, thenEnter, thenCtrl+Xto exit nano). - Restart WSL to apply the changes: Open a Windows Command Prompt or PowerShell and run:
Now reopen your Ubuntu terminal—your Windows files underwsl --shutdown/mnt/c(or other drives) should have the correct permissions.
方法2:在Windows中调整特定文件/文件夹的权限
If you only need to fix permissions for a single file or folder, you can adjust Windows' native security settings:
- Locate the target file/folder in Windows File Explorer, right-click it, and select Properties.
- Go to the Security tab, then click Edit to modify permissions.
- Click Add, type
Authenticated Usersinto the text box, then click Check Names (it should auto-complete the full name). Click OK. - In the permissions list for
Authenticated Users, check the boxes for:- Read & Execute
- List Folder Contents
- Read
If you need to modify the file/folder from Ubuntu, also check Write.
- For folders, check the box at the bottom that says Replace all child object permission entries with inheritable permission entries from this object to apply the settings to all subfiles/folders.
- Click Apply then OK to save changes. Go back to Ubuntu and try accessing the file again—it should work now.
A quick note: Avoid setting permissions for the Everyone group unless absolutely necessary, as it's a security risk. The sudo chmod command you tried only modifies the WSL permission layer, not the actual Windows security settings, so it won't stick long-term or fix the root issue.
内容的提问来源于stack exchange,提问作者Sritam Jagadev

