I'm trying to learn Linux essentials on WSL. I tried to change permission for a test file and it didn't work as I expected.
$ stat test.sh
File: test.sh
Size: 1616 Blocks: 8 IO Block: 4096 regular file
Device: eh/14d Inode: 93168217291239796 Links: 1
Access: (0777/-rwxrwxrwx) Uid: ( 1000/merajmasuk) Gid: ( 1000/merajmasuk)
Access: 2019-11-25 01:42:24.306619600 +0600
Modify: 2019-11-25 01:42:24.306619600 +0600
Change: 2019-11-25 12:44:11.615101900 +0600
Birth: -
$ chmod 444 test.sh
$ stat test.sh
File: test.sh
Size: 1616 Blocks: 8 IO Block: 4096 regular file
Device: eh/14d Inode: 93168217291239796 Links: 1
Access: (0555/-r-xr-xr-x) Uid: ( 1000/merajmasuk) Gid: ( 1000/merajmasuk)
Access: 2019-11-25 01:42:24.306619600 +0600
Modify: 2019-11-25 01:42:24.306619600 +0600
Change: 2019-11-25 12:49:02.544253700 +0600
Birth: -
As you can see, I tried to apply the permission 444, here 555 was applied. Another example,
$ stat test.sh
File: test.sh
Size: 1616 Blocks: 8 IO Block: 4096 regular file
Device: eh/14d Inode: 93168217291239796 Links: 1
Access: (0555/-r-xr-xr-x) Uid: ( 1000/merajmasuk) Gid: ( 1000/merajmasuk)
Access: 2019-11-25 01:42:24.306619600 +0600
Modify: 2019-11-25 01:42:24.306619600 +0600
Change: 2019-11-25 12:49:02.544253700 +0600
Birth: -
$ chmod 711 test.sh
$ stat test.sh
File: test.sh
Size: 1616 Blocks: 8 IO Block: 4096 regular file
Device: eh/14d Inode: 93168217291239796 Links: 1
Access: (0777/-rwxrwxrwx) Uid: ( 1000/merajmasuk) Gid: ( 1000/merajmasuk)
Access: 2019-11-25 01:42:24.306619600 +0600
Modify: 2019-11-25 01:42:24.306619600 +0600
Change: 2019-11-25 12:52:27.316596700 +0600
Birth: -
Which, again you can see, doesn't work correctly.
I looked at this question but it didn't help me. I found a similar post (as my machine uses NTFS partition and the file is inside /mnt) on AskUbuntu but I found it too complex for me.
/homeor is it under/mnt? Filesystems in WSL1 work a bit differently than in standalone Linux, so anything that mentions "ntfs-3g" does not apply. – u1686_grawity Nov 25 '19 at 07:08/mnt. – Meraj al Maksud Nov 25 '19 at 09:33chmodunless I copy the file outside/mnt? – Meraj al Maksud Nov 25 '19 at 09:35mount | grep mnt, do you see any mention of aumaskorfmask? That is often a limitation on the permissions you can set on files on that partition. – Jim Danner Nov 25 '19 at 09:44/mntworks differently from the "main" WSL filesystem, I'm not sure if it supports permission mapping at all. (The usual problem is that NTFS permissions are a bit more expressive than Linux permissions.) – u1686_grawity Nov 25 '19 at 09:46C:\ on /mnt/c type drvfs (rw,noatime,uid=1000,gid=1000,case=off) D:\ on /mnt/d type drvfs (rw,noatime,uid=1000,gid=1000,case=off) F:\ on /mnt/f type drvfs (rw,noatime,uid=1000,gid=1000,case=off) I:\ on /mnt/i type drvfs (rw,noatime,uid=1000,gid=1000,case=off)– Meraj al Maksud Nov 25 '19 at 09:46