chmod WSL (Bash) doesn't work

前端 未结 3 1322
不思量自难忘°
不思量自难忘° 2020-12-23 21:13

Running bash on windows 10, the simple syntax below works when I SSH to my webserver, but not when I exit out and am on my local machine. It doesn\'t give me an error, but I

相关标签:
3条回答
  • 2020-12-23 21:59

    Both Amades and Chaos answers are correct. But it only works for local drives not for mapped network drives. Z: is one of my network drives. Same operation on /mnt/c/Users/xxx/ works fine.

    $sudo mount -t drvfs Z: /mnt/z -o metadata
    $touch test
    $chmod +w test
     chmod: changing permissions of 'test': Operation not permitted
    

    This is a known issue, see drvfs: metadata (chmod\chown) possible for mounted SMB drives?

    0 讨论(0)
  • 2020-12-23 22:00

    There was an update to WSL recently (source), which lets you change permissions to files (Insider Build 17063).

    All you have to do is to run:

    sudo umount /mnt/c
    sudo mount -t drvfs C: /mnt/c -o metadata
    
    0 讨论(0)
  • 2020-12-23 22:13

    Amade's answer is correct, but please note, the cmd only take effect in session scope. If you exit current bash, you'll lose your setting.

    To fix this, you need to edit /etc/wsl.conf. and put below config in.

    [automount]
    enabled = true
    options = "metadata"
    

    Ref:

    Automatically Configuring WSL

    Chmod/Chown WSL Improvements

    0 讨论(0)
提交回复
热议问题