0

I have 2 users test(has access to sudo) and testuser1 (has no access to sudo).

I need to make child3 and file.txt ownership and permissions only for testuser1 (which are created by user test)

/home/test/some_test/parent1/child3/file.txt

However when I do

sudo chown testuser1:testuser1 -R child3
sudo chmod 700 -R child3

I get

drwx------ 2 testuser1 testuser1 4096 Sep 30 00:39 child3

So I can't access to folder as another user (which is correct) but I can't also delete folder as testuser1, only test user can

Jay
  • 3
  • 1

1 Answers1

3

This is normal. You have set the permissions for /home/test/some_test/parent1/child3 and files therein. However, that folder resides in /home/test/some_test/parent1. Deleting that folder involves changing /home/test/some_test/parent1. Thus, permissions of the folder parent1 determine whether testuser1can delete (or create) a folder there.

If you want the user to also be able to delete the folder itself, you need to put it in a folder where that user also has write access (somewhere under the user's home folder is a good place).

Alternatively, you need to provide the user read+write access to the parent1 folder, but that involves inevitably that that user will be able to rename and delete any files present in that folder.

The default linux file permission system essentially is rather basic. For more granular control of permissions, there is the feature of Access Control Lists (ACL).

vanadium
  • 97,564