Any way to force files to inherit owner permissions from parent directory?











up vote
3
down vote

favorite












Is there any way to force a file, created within a directory, to inherit ownership from the parent directory? I tried the sticky bit, but that doesn't seem to work.



Example of what I'm looking for:



drwxrwxr-x www-data somegroup parentdir


When parentdir/newfile.htm is created by someuser:



-rwxrwxr-x www-data somegroup newfile.htm


NOT



-rwxr-xr-x someuser somegroup newfile.htm


Any way this can be done? Thank you!










share|improve this question






















  • The sticky bit or the setgid bit?
    – muru
    May 22 '15 at 6:23










  • @muru, I believe they're one in the same. What I'm calling the sticky bit is the flag that makes sure children inherit the group owner from the parent directory.
    – S. Wyatt Young
    May 22 '15 at 22:51










  • That's the setgid bit. The sticky bit is what you see on /tmp - which prevents others from deleting your files.
    – muru
    May 22 '15 at 23:29










  • @muru: Ah! Thank you for clarifying that bit for me.
    – S. Wyatt Young
    May 23 '15 at 3:26

















up vote
3
down vote

favorite












Is there any way to force a file, created within a directory, to inherit ownership from the parent directory? I tried the sticky bit, but that doesn't seem to work.



Example of what I'm looking for:



drwxrwxr-x www-data somegroup parentdir


When parentdir/newfile.htm is created by someuser:



-rwxrwxr-x www-data somegroup newfile.htm


NOT



-rwxr-xr-x someuser somegroup newfile.htm


Any way this can be done? Thank you!










share|improve this question






















  • The sticky bit or the setgid bit?
    – muru
    May 22 '15 at 6:23










  • @muru, I believe they're one in the same. What I'm calling the sticky bit is the flag that makes sure children inherit the group owner from the parent directory.
    – S. Wyatt Young
    May 22 '15 at 22:51










  • That's the setgid bit. The sticky bit is what you see on /tmp - which prevents others from deleting your files.
    – muru
    May 22 '15 at 23:29










  • @muru: Ah! Thank you for clarifying that bit for me.
    – S. Wyatt Young
    May 23 '15 at 3:26















up vote
3
down vote

favorite









up vote
3
down vote

favorite











Is there any way to force a file, created within a directory, to inherit ownership from the parent directory? I tried the sticky bit, but that doesn't seem to work.



Example of what I'm looking for:



drwxrwxr-x www-data somegroup parentdir


When parentdir/newfile.htm is created by someuser:



-rwxrwxr-x www-data somegroup newfile.htm


NOT



-rwxr-xr-x someuser somegroup newfile.htm


Any way this can be done? Thank you!










share|improve this question













Is there any way to force a file, created within a directory, to inherit ownership from the parent directory? I tried the sticky bit, but that doesn't seem to work.



Example of what I'm looking for:



drwxrwxr-x www-data somegroup parentdir


When parentdir/newfile.htm is created by someuser:



-rwxrwxr-x www-data somegroup newfile.htm


NOT



-rwxr-xr-x someuser somegroup newfile.htm


Any way this can be done? Thank you!







permissions






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked May 22 '15 at 6:00









S. Wyatt Young

1612




1612












  • The sticky bit or the setgid bit?
    – muru
    May 22 '15 at 6:23










  • @muru, I believe they're one in the same. What I'm calling the sticky bit is the flag that makes sure children inherit the group owner from the parent directory.
    – S. Wyatt Young
    May 22 '15 at 22:51










  • That's the setgid bit. The sticky bit is what you see on /tmp - which prevents others from deleting your files.
    – muru
    May 22 '15 at 23:29










  • @muru: Ah! Thank you for clarifying that bit for me.
    – S. Wyatt Young
    May 23 '15 at 3:26




















  • The sticky bit or the setgid bit?
    – muru
    May 22 '15 at 6:23










  • @muru, I believe they're one in the same. What I'm calling the sticky bit is the flag that makes sure children inherit the group owner from the parent directory.
    – S. Wyatt Young
    May 22 '15 at 22:51










  • That's the setgid bit. The sticky bit is what you see on /tmp - which prevents others from deleting your files.
    – muru
    May 22 '15 at 23:29










  • @muru: Ah! Thank you for clarifying that bit for me.
    – S. Wyatt Young
    May 23 '15 at 3:26


















The sticky bit or the setgid bit?
– muru
May 22 '15 at 6:23




The sticky bit or the setgid bit?
– muru
May 22 '15 at 6:23












@muru, I believe they're one in the same. What I'm calling the sticky bit is the flag that makes sure children inherit the group owner from the parent directory.
– S. Wyatt Young
May 22 '15 at 22:51




@muru, I believe they're one in the same. What I'm calling the sticky bit is the flag that makes sure children inherit the group owner from the parent directory.
– S. Wyatt Young
May 22 '15 at 22:51












That's the setgid bit. The sticky bit is what you see on /tmp - which prevents others from deleting your files.
– muru
May 22 '15 at 23:29




That's the setgid bit. The sticky bit is what you see on /tmp - which prevents others from deleting your files.
– muru
May 22 '15 at 23:29












@muru: Ah! Thank you for clarifying that bit for me.
– S. Wyatt Young
May 23 '15 at 3:26






@muru: Ah! Thank you for clarifying that bit for me.
– S. Wyatt Young
May 23 '15 at 3:26












1 Answer
1






active

oldest

votes

















up vote
0
down vote













You problem (it's not really a problem) raises in two parts as I understand from you.



First you want to give ownership of files created by a user in that directory directly to the apache user www-data. This can't be done that way.



In real life You can't give something to your friend if he doesn't want it!!



Same thing here, you can't give the ownership to some user without his permission.



So how to solve this here:



you still need to make chown



sudo chown www-data newfile.htm


The other needed is to change the permission of a file to inherits permission of parent directory.



This is not a good habit since the directory normally have execute permission x to make cd available in. But x for a normal file make it executable, and as those files as you mentioned are owned by www-data, this also makes you in trouble with a huge security threat, so my advice don't do it



But anyway if you still want to try : take a look for those two questions



https://superuser.com/questions/264383/how-to-set-file-permissions-so-that-new-files-inherit-same-permissions



https://superuser.com/questions/151911/how-to-make-new-file-permission-inherit-from-the-parent-directory






share|improve this answer























  • Not what I'm looking for. I'm looking to avoid changing permissions manually. Also, while HTML files don't need executability, scripts do. I might just be running scripts. :)
    – S. Wyatt Young
    May 22 '15 at 22:55











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f626841%2fany-way-to-force-files-to-inherit-owner-permissions-from-parent-directory%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote













You problem (it's not really a problem) raises in two parts as I understand from you.



First you want to give ownership of files created by a user in that directory directly to the apache user www-data. This can't be done that way.



In real life You can't give something to your friend if he doesn't want it!!



Same thing here, you can't give the ownership to some user without his permission.



So how to solve this here:



you still need to make chown



sudo chown www-data newfile.htm


The other needed is to change the permission of a file to inherits permission of parent directory.



This is not a good habit since the directory normally have execute permission x to make cd available in. But x for a normal file make it executable, and as those files as you mentioned are owned by www-data, this also makes you in trouble with a huge security threat, so my advice don't do it



But anyway if you still want to try : take a look for those two questions



https://superuser.com/questions/264383/how-to-set-file-permissions-so-that-new-files-inherit-same-permissions



https://superuser.com/questions/151911/how-to-make-new-file-permission-inherit-from-the-parent-directory






share|improve this answer























  • Not what I'm looking for. I'm looking to avoid changing permissions manually. Also, while HTML files don't need executability, scripts do. I might just be running scripts. :)
    – S. Wyatt Young
    May 22 '15 at 22:55















up vote
0
down vote













You problem (it's not really a problem) raises in two parts as I understand from you.



First you want to give ownership of files created by a user in that directory directly to the apache user www-data. This can't be done that way.



In real life You can't give something to your friend if he doesn't want it!!



Same thing here, you can't give the ownership to some user without his permission.



So how to solve this here:



you still need to make chown



sudo chown www-data newfile.htm


The other needed is to change the permission of a file to inherits permission of parent directory.



This is not a good habit since the directory normally have execute permission x to make cd available in. But x for a normal file make it executable, and as those files as you mentioned are owned by www-data, this also makes you in trouble with a huge security threat, so my advice don't do it



But anyway if you still want to try : take a look for those two questions



https://superuser.com/questions/264383/how-to-set-file-permissions-so-that-new-files-inherit-same-permissions



https://superuser.com/questions/151911/how-to-make-new-file-permission-inherit-from-the-parent-directory






share|improve this answer























  • Not what I'm looking for. I'm looking to avoid changing permissions manually. Also, while HTML files don't need executability, scripts do. I might just be running scripts. :)
    – S. Wyatt Young
    May 22 '15 at 22:55













up vote
0
down vote










up vote
0
down vote









You problem (it's not really a problem) raises in two parts as I understand from you.



First you want to give ownership of files created by a user in that directory directly to the apache user www-data. This can't be done that way.



In real life You can't give something to your friend if he doesn't want it!!



Same thing here, you can't give the ownership to some user without his permission.



So how to solve this here:



you still need to make chown



sudo chown www-data newfile.htm


The other needed is to change the permission of a file to inherits permission of parent directory.



This is not a good habit since the directory normally have execute permission x to make cd available in. But x for a normal file make it executable, and as those files as you mentioned are owned by www-data, this also makes you in trouble with a huge security threat, so my advice don't do it



But anyway if you still want to try : take a look for those two questions



https://superuser.com/questions/264383/how-to-set-file-permissions-so-that-new-files-inherit-same-permissions



https://superuser.com/questions/151911/how-to-make-new-file-permission-inherit-from-the-parent-directory






share|improve this answer














You problem (it's not really a problem) raises in two parts as I understand from you.



First you want to give ownership of files created by a user in that directory directly to the apache user www-data. This can't be done that way.



In real life You can't give something to your friend if he doesn't want it!!



Same thing here, you can't give the ownership to some user without his permission.



So how to solve this here:



you still need to make chown



sudo chown www-data newfile.htm


The other needed is to change the permission of a file to inherits permission of parent directory.



This is not a good habit since the directory normally have execute permission x to make cd available in. But x for a normal file make it executable, and as those files as you mentioned are owned by www-data, this also makes you in trouble with a huge security threat, so my advice don't do it



But anyway if you still want to try : take a look for those two questions



https://superuser.com/questions/264383/how-to-set-file-permissions-so-that-new-files-inherit-same-permissions



https://superuser.com/questions/151911/how-to-make-new-file-permission-inherit-from-the-parent-directory







share|improve this answer














share|improve this answer



share|improve this answer








edited Mar 20 '17 at 10:18









Community

1




1










answered May 22 '15 at 6:19









Maythux

50.1k32164214




50.1k32164214












  • Not what I'm looking for. I'm looking to avoid changing permissions manually. Also, while HTML files don't need executability, scripts do. I might just be running scripts. :)
    – S. Wyatt Young
    May 22 '15 at 22:55


















  • Not what I'm looking for. I'm looking to avoid changing permissions manually. Also, while HTML files don't need executability, scripts do. I might just be running scripts. :)
    – S. Wyatt Young
    May 22 '15 at 22:55
















Not what I'm looking for. I'm looking to avoid changing permissions manually. Also, while HTML files don't need executability, scripts do. I might just be running scripts. :)
– S. Wyatt Young
May 22 '15 at 22:55




Not what I'm looking for. I'm looking to avoid changing permissions manually. Also, while HTML files don't need executability, scripts do. I might just be running scripts. :)
– S. Wyatt Young
May 22 '15 at 22:55


















draft saved

draft discarded




















































Thanks for contributing an answer to Ask Ubuntu!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f626841%2fany-way-to-force-files-to-inherit-owner-permissions-from-parent-directory%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Quarter-circle Tiles

build a pushdown automaton that recognizes the reverse language of a given pushdown automaton?

Mont Emei