cshuo
cshuo

Reputation: 45

Permissions of pyfilesystem when removing files

I am confused about the permission of pyfilesystem operation, look at the following code:

from fs.osfs import OSFS

a = OSFS('test')
a.remove('new1')
a.remove('new2')

and the ownership of these two files is:

-rw-rw-r-- 1 monkey monkey    0  1月 14 15:34 new1   
-rw-r--r-- 1 root   root      0  1月 14 15:34 new2   

The result is that I can remove new2 with "root, root" ownership, besides, when I use pyfilesystem to create a file, the ownership is "monkey, monkey". Can anyone can explain?

Upvotes: 1

Views: 157

Answers (1)

Shengwei
Shengwei

Reputation: 526

This is not a issue on pyfilesystem. This is a normal phenomenon in linux.

When you remove a file, the permission of the enclosing directory rather than the one of the removed file matters.

In this case, you maybe have the write permission of the directory, so you can remove new2 file.

Therefore, you can also use rm new2 to remove new2 in your bash.

Upvotes: 2

Related Questions