WSL 中默认的文件权限是 777,把它修改为和 Linux 默认的一致(目录 755,文件 644)。
WSL 目录下的文件
在.profile
或.zshenv
或中加入:
1 | if [[ "$(umask)" == '000' ]]; then |
Windows 目录下的文件
在/etc/wsl.conf
中加入(如果文件不存在,就新建一个):
1 | [automount] |
如果在options
中直接设置umask=022
或者设置中包含fmask=133
, wsl-terminal 和 WSLtty 将无法运行,而从 Windows Store 安装的 WSL 程序可以运行。猜测是因为 wsl-terminal 和 WSLtty 的可执行程序以 644 的权限挂载,导致没有运行权限而无法运行。可能的解决方法(未验证),设置mountFsTab = true
,然后在etc/fstab
中单独设置每个盘的挂载选项,把 wsl-terminal 或 WSLtty 所在的盘以 744 的权限(fmask = 033)挂载。
References
1. http://zuyunfei.com/2018/06/15/file-system-configuration-in-wsl/ ↩
2. https://blogs.msdn.microsoft.com/commandline/2018/02/07/automatically-configuring-wsl/ ↩