0

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.

Meraj al Maksud
  • 190
  • 2
  • 15
  • 1
    Is the file located within the WSL `/home` or 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
  • To elaborate on what @grawity said, check out [this](https://superuser.com/a/1322665/529800) answer from simpleuser – JW0914 Nov 25 '19 at 07:47
  • @grawity it's within `/mnt`. – Meraj al Maksud Nov 25 '19 at 09:33
  • So, you are trying to imply that there is no way of applying `chmod` unless I copy the file outside `/mnt`? – Meraj al Maksud Nov 25 '19 at 09:35
  • If you look how this partition was mounted, `mount | grep mnt`, do you see any mention of a `umask` or `fmask`? That is often a limitation on the permissions you can set on files on that partition. – Jim Danner Nov 25 '19 at 09:44
  • On WSL, `/mnt` works 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:46
  • @JimDanner This is what I get: ```C:\ 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
  • 1
    Possible duplicate of [Unable to change file permissions on Ubuntu Bash for Windows 10](https://superuser.com/questions/1323645/unable-to-change-file-permissions-on-ubuntu-bash-for-windows-10) – Biswapriyo Nov 28 '19 at 14:38

0 Answers0