5

I am working on wsl2 of win10:

PS C:\Users\Gaowei> wsl -l -v
  NAME            STATE           VERSION
* Ubuntu-20.04    Running         2

After entering wsl, I make a file of test.md:

➜  ~ ls -l test.md
-rwxrwxrwx 1 gaowei gaowei 0 Aug 25 17:17 test.md

then try to change its permissions:

➜  ~ chmod 755 test.md
➜  ~ ls -l test.md
-rwxrwxrwx 1 gaowei gaowei 0 Aug 25 17:17 test.md
➜  ~ sudo chmod 755 test.md
➜  ~ ls -l test.md
-rwxrwxrwx 1 gaowei gaowei 0 Aug 25 17:17 test.md

Unfortunately, it turn out to be stay unchanged.

My machine info:

gaowei@Spiritme
---------------
OS: Ubuntu 20.04.1 LTS on Windows 10 x86_64
Kernel: 4.19.104-microsoft-standard
Uptime: 4 mins
Packages: 1068 (dpkg)
Shell: zsh 5.8
Terminal: /dev/pts/0
CPU: AMD Ryzen 5 4500U with Radeon Graphics (6) @ 2.370GHz
Memory: 75MiB / 12277MiB

what's the problem it might be?

AbstProcDo
  • 17,381
  • 14
  • 68
  • 114

1 Answers1

8

The problem was solved by creating /etc/wsl.conf file and configuring it as:

# Enable extra metadata options by default
[automount]
enabled = true
root = /mnt/
options = "metadata,umask=22,fmask=11"
mountFsTab = false
# Enable DNS – even though these are turned on by default, we'll specify here just to be explicit.
[network]
generateHosts = true
generateResolvConf = true

Reference : wsl.conf

NotTheDr01ds
  • 8,135
  • 1
  • 22
  • 45
AbstProcDo
  • 17,381
  • 14
  • 68
  • 114
  • 2
    Can you explain a little why this configuration is supposed to fix the issue? thanks – funder7 May 30 '21 at 18:09
  • 3
    The `options = "metadata"` section is what is needed. See https://stackoverflow.com/a/50856772/1880761 for more detail. – trebor Jul 01 '21 at 17:42