Resolve the windows file’s highest permission in WSL


WSL windows subsystem Linux

In WSL, windows directories exist in the / MNT directory. LS – l can see that WSL has 777 highest options in windows.
Resolve the windows file's highest permission in WSL

However, when we want to change the file option to use Chmod 0600 file, we cannot change the permissions of the file. At this time, we will change the mount mode of / MNT / d.
Solution details from Microsoft Help
You can now use Chmod / chown to set the owner and group of files and modify read / write / execute permissions in WSL. You can also create special files, such as FIFOs, UNIX sockets, and device files. We have introduced new installation options in drvfs to project permissions to files and provide new Linux metadata on files and folders.

There is also a step you must take before you can enjoy these new features: you must uninstall drvfs and reinstall it with the “metadata” flag. To do this:

#Use Disk C or D or other as needed
sudo umount /mnt/d
sudo mount -t drvfs D: /mnt/d -o metadata

At this point, WSL has the right to replace Windows files at will.