The meaning of life is to explore the world

How to fix: chmod doesn't work in WSL

Posted on By Jason Liu

Problem:
After chmod, the permissions got lost due to being overwritten by Windows

Solution:
The correct way to handle this:

Create a file named /etc/wsl.conf and edit it to contain the following:

[automount]
enabled = true
root = /mnt/
options = "metadata,umask=22,fmask=11"

To understand the meaning of each parameter above, please refer to this article on msdn:

Close all open WSL terminal then open a new one.

Now you are all set, changing permissions of a file in windows from /mnt/c/ will be reflected correctly on the Linux Subsystem through the WSL “metadata” feature.

The WSL configuration will always mount correctly on startup of WSL.