chmod: I own the folders, but I can only delete the folder, not the files inside it

1

Hello I new to linux and i have searched about 10 hours for a answer without success.

I have created a folder called "Datatank" and chmod 777 Datatank

All files and folder inside Datatank can I delete.

But if nobody user creates a folder inside Datatank, i can delete that folder. But if nobody user creates a folder a put files inside it i cant delete the files, only the whole folder.

Is is posible to give the parrent directory owner full access to all sub directories and files ?

I want all subfolders and files to inhert the permission from the parrent folder. So whoever can create a folder and i can delete files and folders inside it.

CasperC

Posted 2013-09-06T13:10:32.683

Reputation: 13

You can't change the owner of a file unless you are the superuser. But there may be another way to do what you want. What exactly is your end goal? You say you want "full access", but is it just that you want to be able to remove the subfiles? Remove the subdirectory? Move the subdirectory out of Datatank? – dg99 – 2013-09-06T13:14:00.693

I want to be able to delete files inside subdirs. I can only delete files/folders inside the parrent dir right now. I got a drive everyone can use, but if someone create a folder and put stuff inside it i cant delete the stuff. only the whole folder. cause i only got access to delete folders and files inside the parrent not inside the folder created by the other users wich is nobody – CasperC – 2013-09-06T13:22:19.477

Then @JustinSane's answer is exactly what you need. If you force everything inside Datatank to inherit your group and group permissions, you'll be able to delete whatever you want, even if the item is owned by another user. – dg99 – 2013-09-06T16:54:55.130

Answers

4

You can set the setgid-flag on the group permission of a directory like this:

chmod g+s folder

This makes every newly created file in that folder inherit the owning group and group permissions of the parent folder. See https://en.wikipedia.org/wiki/Setuid

Justin Sane

Posted 2013-09-06T13:10:32.683

Reputation: 66

Hmm,, but then the "guests" also inhert my permissions and can delete my stuff ? – CasperC – 2013-09-06T18:25:41.557

Only if they are members of the owning group. Most likely, that is your personal group with the same name as your username, so if they have their write permission to your folder by the "other" permissions, and you do ´chmod o-w´ on your own files, they can't delete them. – Justin Sane – 2013-09-06T18:38:02.000