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
  • `sudo chmod 700 -R child3` sets access rights to `drwx------ ` .. that is correct. What access rights do you want ? – Soren A Sep 30 '20 at 08:00
  • @SorenA It's not about access rights maybe?, I can't delete the folder when logged as testuser1 using sudo su - testuser1 – Jay Sep 30 '20 at 08:04
  • How do you try to delete the folder, and what errors do you get ? – Soren A Sep 30 '20 at 08:16
  • 5
    Does this answer your question? [rm: cannot remove directory/: Permission denied](https://askubuntu.com/questions/793507/rm-cannot-remove-directory-permission-denied) If not, please [edit] your question to show the permissions to the `parent1` folder. – Melebius Sep 30 '20 at 08:18

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
  • 82,909
  • 6
  • 116
  • 186
  • That was it! Thanks. The problem was that parent folder didn't have any permissions for others to write – Jay Sep 30 '20 at 08:44