Ubuntu set permissions for future created files












0















I create a file host.txt and add some data



I debug PHP for 3 hours, only to know that PHP couldn't write to the file. How can I set default 775 permissions on all files that are created from now on on that folder?



sudo groupadd powerusers
sudo usermod -a -G powerusers richard
sudo usermod -a -G powerusers nginx
sudo usermod -a -G powerusers php-fpm
usermod -a -G powerusers root
sudo mkdir -p /var/www/public_html
sudo chgrp -R powerusers /var/www/public_html
chown -R nginx:powerusers /var/www/public_html
sudo chmod -R 775 /var/www/public_html
sudo systemctl restart nginx









share|improve this question




















  • 3





    "How can I set default 775 permissions on all files that are created from now on?" you do not want that. Trust me on that one. 750 for dirs and 640 for files (0 for others as you should use user or group to make it available for writing and reading). A "host.txt" should not be executable as it holds plain text and not something to execute

    – Rinzwind
    Jan 14 at 12:11


















0















I create a file host.txt and add some data



I debug PHP for 3 hours, only to know that PHP couldn't write to the file. How can I set default 775 permissions on all files that are created from now on on that folder?



sudo groupadd powerusers
sudo usermod -a -G powerusers richard
sudo usermod -a -G powerusers nginx
sudo usermod -a -G powerusers php-fpm
usermod -a -G powerusers root
sudo mkdir -p /var/www/public_html
sudo chgrp -R powerusers /var/www/public_html
chown -R nginx:powerusers /var/www/public_html
sudo chmod -R 775 /var/www/public_html
sudo systemctl restart nginx









share|improve this question




















  • 3





    "How can I set default 775 permissions on all files that are created from now on?" you do not want that. Trust me on that one. 750 for dirs and 640 for files (0 for others as you should use user or group to make it available for writing and reading). A "host.txt" should not be executable as it holds plain text and not something to execute

    – Rinzwind
    Jan 14 at 12:11
















0












0








0








I create a file host.txt and add some data



I debug PHP for 3 hours, only to know that PHP couldn't write to the file. How can I set default 775 permissions on all files that are created from now on on that folder?



sudo groupadd powerusers
sudo usermod -a -G powerusers richard
sudo usermod -a -G powerusers nginx
sudo usermod -a -G powerusers php-fpm
usermod -a -G powerusers root
sudo mkdir -p /var/www/public_html
sudo chgrp -R powerusers /var/www/public_html
chown -R nginx:powerusers /var/www/public_html
sudo chmod -R 775 /var/www/public_html
sudo systemctl restart nginx









share|improve this question
















I create a file host.txt and add some data



I debug PHP for 3 hours, only to know that PHP couldn't write to the file. How can I set default 775 permissions on all files that are created from now on on that folder?



sudo groupadd powerusers
sudo usermod -a -G powerusers richard
sudo usermod -a -G powerusers nginx
sudo usermod -a -G powerusers php-fpm
usermod -a -G powerusers root
sudo mkdir -p /var/www/public_html
sudo chgrp -R powerusers /var/www/public_html
chown -R nginx:powerusers /var/www/public_html
sudo chmod -R 775 /var/www/public_html
sudo systemctl restart nginx






14.04 chmod






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 15 at 8:48









Codito ergo sum

1,5023825




1,5023825










asked Jan 14 at 12:07









Born vs. MeBorn vs. Me

115




115








  • 3





    "How can I set default 775 permissions on all files that are created from now on?" you do not want that. Trust me on that one. 750 for dirs and 640 for files (0 for others as you should use user or group to make it available for writing and reading). A "host.txt" should not be executable as it holds plain text and not something to execute

    – Rinzwind
    Jan 14 at 12:11
















  • 3





    "How can I set default 775 permissions on all files that are created from now on?" you do not want that. Trust me on that one. 750 for dirs and 640 for files (0 for others as you should use user or group to make it available for writing and reading). A "host.txt" should not be executable as it holds plain text and not something to execute

    – Rinzwind
    Jan 14 at 12:11










3




3





"How can I set default 775 permissions on all files that are created from now on?" you do not want that. Trust me on that one. 750 for dirs and 640 for files (0 for others as you should use user or group to make it available for writing and reading). A "host.txt" should not be executable as it holds plain text and not something to execute

– Rinzwind
Jan 14 at 12:11







"How can I set default 775 permissions on all files that are created from now on?" you do not want that. Trust me on that one. 750 for dirs and 640 for files (0 for others as you should use user or group to make it available for writing and reading). A "host.txt" should not be executable as it holds plain text and not something to execute

– Rinzwind
Jan 14 at 12:11












1 Answer
1






active

oldest

votes


















0














I would advice you to not set 775 as default. But if you really want to you can either use umask which will show you your current default and lets you set a new default.



Or you'll use this: chmod 775 filename.txt>>!#:2 from now on for files you are certain that should have these access rights.



I would advice you to adjust the permissions individually.



Stole this from here: https://stackoverflow.com/questions/21342371/single-command-to-create-a-file-and-set-its-permission



Hope that helps!



@Edit: umask 0002 ("Default is 0022, If I am not mistaken")






share|improve this answer


























  • Can you plerase provice an example code umask?

    – Born vs. Me
    Jan 14 at 12:26











  • There you go, I've edited it. umask 0775 should do it. Hope that helps. You can use man umask to bring up the man-page and find out more about the command. As you should be able to tell its just like chmod, it uses octal codes to determine permissions. en.wikipedia.org/wiki/Umask

    – Patient32Bit
    Jan 14 at 12:34













  • I cant afford to sert the permissiopns individually I need to put a chmod for all files in that follder, including future ones

    – Born vs. Me
    Jan 14 at 12:38











  • That information helps a lot. So you want all files created in that folder and below to have 0755? I can't think of an easy way to do that. You could run an Cronjob every minute setting all files in that directory to 755 with chmod. Would that do the trick?

    – Patient32Bit
    Jan 14 at 12:43








  • 1





    @Patient32Bit umask 0775 will not set 775 permissions to a file. 0022 wil set 644 to a file and 755 for a directory. I think umask 0775 wil set 001 for files and 002 for directories. Read this cyberciti.biz/tips/….

    – nobody
    Jan 14 at 12:56













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',
autoActivateHeartbeat: false,
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%2f1109617%2fubuntu-set-permissions-for-future-created-files%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









0














I would advice you to not set 775 as default. But if you really want to you can either use umask which will show you your current default and lets you set a new default.



Or you'll use this: chmod 775 filename.txt>>!#:2 from now on for files you are certain that should have these access rights.



I would advice you to adjust the permissions individually.



Stole this from here: https://stackoverflow.com/questions/21342371/single-command-to-create-a-file-and-set-its-permission



Hope that helps!



@Edit: umask 0002 ("Default is 0022, If I am not mistaken")






share|improve this answer


























  • Can you plerase provice an example code umask?

    – Born vs. Me
    Jan 14 at 12:26











  • There you go, I've edited it. umask 0775 should do it. Hope that helps. You can use man umask to bring up the man-page and find out more about the command. As you should be able to tell its just like chmod, it uses octal codes to determine permissions. en.wikipedia.org/wiki/Umask

    – Patient32Bit
    Jan 14 at 12:34













  • I cant afford to sert the permissiopns individually I need to put a chmod for all files in that follder, including future ones

    – Born vs. Me
    Jan 14 at 12:38











  • That information helps a lot. So you want all files created in that folder and below to have 0755? I can't think of an easy way to do that. You could run an Cronjob every minute setting all files in that directory to 755 with chmod. Would that do the trick?

    – Patient32Bit
    Jan 14 at 12:43








  • 1





    @Patient32Bit umask 0775 will not set 775 permissions to a file. 0022 wil set 644 to a file and 755 for a directory. I think umask 0775 wil set 001 for files and 002 for directories. Read this cyberciti.biz/tips/….

    – nobody
    Jan 14 at 12:56


















0














I would advice you to not set 775 as default. But if you really want to you can either use umask which will show you your current default and lets you set a new default.



Or you'll use this: chmod 775 filename.txt>>!#:2 from now on for files you are certain that should have these access rights.



I would advice you to adjust the permissions individually.



Stole this from here: https://stackoverflow.com/questions/21342371/single-command-to-create-a-file-and-set-its-permission



Hope that helps!



@Edit: umask 0002 ("Default is 0022, If I am not mistaken")






share|improve this answer


























  • Can you plerase provice an example code umask?

    – Born vs. Me
    Jan 14 at 12:26











  • There you go, I've edited it. umask 0775 should do it. Hope that helps. You can use man umask to bring up the man-page and find out more about the command. As you should be able to tell its just like chmod, it uses octal codes to determine permissions. en.wikipedia.org/wiki/Umask

    – Patient32Bit
    Jan 14 at 12:34













  • I cant afford to sert the permissiopns individually I need to put a chmod for all files in that follder, including future ones

    – Born vs. Me
    Jan 14 at 12:38











  • That information helps a lot. So you want all files created in that folder and below to have 0755? I can't think of an easy way to do that. You could run an Cronjob every minute setting all files in that directory to 755 with chmod. Would that do the trick?

    – Patient32Bit
    Jan 14 at 12:43








  • 1





    @Patient32Bit umask 0775 will not set 775 permissions to a file. 0022 wil set 644 to a file and 755 for a directory. I think umask 0775 wil set 001 for files and 002 for directories. Read this cyberciti.biz/tips/….

    – nobody
    Jan 14 at 12:56
















0












0








0







I would advice you to not set 775 as default. But if you really want to you can either use umask which will show you your current default and lets you set a new default.



Or you'll use this: chmod 775 filename.txt>>!#:2 from now on for files you are certain that should have these access rights.



I would advice you to adjust the permissions individually.



Stole this from here: https://stackoverflow.com/questions/21342371/single-command-to-create-a-file-and-set-its-permission



Hope that helps!



@Edit: umask 0002 ("Default is 0022, If I am not mistaken")






share|improve this answer















I would advice you to not set 775 as default. But if you really want to you can either use umask which will show you your current default and lets you set a new default.



Or you'll use this: chmod 775 filename.txt>>!#:2 from now on for files you are certain that should have these access rights.



I would advice you to adjust the permissions individually.



Stole this from here: https://stackoverflow.com/questions/21342371/single-command-to-create-a-file-and-set-its-permission



Hope that helps!



@Edit: umask 0002 ("Default is 0022, If I am not mistaken")







share|improve this answer














share|improve this answer



share|improve this answer








edited Jan 14 at 13:01

























answered Jan 14 at 12:21









Patient32BitPatient32Bit

816




816













  • Can you plerase provice an example code umask?

    – Born vs. Me
    Jan 14 at 12:26











  • There you go, I've edited it. umask 0775 should do it. Hope that helps. You can use man umask to bring up the man-page and find out more about the command. As you should be able to tell its just like chmod, it uses octal codes to determine permissions. en.wikipedia.org/wiki/Umask

    – Patient32Bit
    Jan 14 at 12:34













  • I cant afford to sert the permissiopns individually I need to put a chmod for all files in that follder, including future ones

    – Born vs. Me
    Jan 14 at 12:38











  • That information helps a lot. So you want all files created in that folder and below to have 0755? I can't think of an easy way to do that. You could run an Cronjob every minute setting all files in that directory to 755 with chmod. Would that do the trick?

    – Patient32Bit
    Jan 14 at 12:43








  • 1





    @Patient32Bit umask 0775 will not set 775 permissions to a file. 0022 wil set 644 to a file and 755 for a directory. I think umask 0775 wil set 001 for files and 002 for directories. Read this cyberciti.biz/tips/….

    – nobody
    Jan 14 at 12:56





















  • Can you plerase provice an example code umask?

    – Born vs. Me
    Jan 14 at 12:26











  • There you go, I've edited it. umask 0775 should do it. Hope that helps. You can use man umask to bring up the man-page and find out more about the command. As you should be able to tell its just like chmod, it uses octal codes to determine permissions. en.wikipedia.org/wiki/Umask

    – Patient32Bit
    Jan 14 at 12:34













  • I cant afford to sert the permissiopns individually I need to put a chmod for all files in that follder, including future ones

    – Born vs. Me
    Jan 14 at 12:38











  • That information helps a lot. So you want all files created in that folder and below to have 0755? I can't think of an easy way to do that. You could run an Cronjob every minute setting all files in that directory to 755 with chmod. Would that do the trick?

    – Patient32Bit
    Jan 14 at 12:43








  • 1





    @Patient32Bit umask 0775 will not set 775 permissions to a file. 0022 wil set 644 to a file and 755 for a directory. I think umask 0775 wil set 001 for files and 002 for directories. Read this cyberciti.biz/tips/….

    – nobody
    Jan 14 at 12:56



















Can you plerase provice an example code umask?

– Born vs. Me
Jan 14 at 12:26





Can you plerase provice an example code umask?

– Born vs. Me
Jan 14 at 12:26













There you go, I've edited it. umask 0775 should do it. Hope that helps. You can use man umask to bring up the man-page and find out more about the command. As you should be able to tell its just like chmod, it uses octal codes to determine permissions. en.wikipedia.org/wiki/Umask

– Patient32Bit
Jan 14 at 12:34







There you go, I've edited it. umask 0775 should do it. Hope that helps. You can use man umask to bring up the man-page and find out more about the command. As you should be able to tell its just like chmod, it uses octal codes to determine permissions. en.wikipedia.org/wiki/Umask

– Patient32Bit
Jan 14 at 12:34















I cant afford to sert the permissiopns individually I need to put a chmod for all files in that follder, including future ones

– Born vs. Me
Jan 14 at 12:38





I cant afford to sert the permissiopns individually I need to put a chmod for all files in that follder, including future ones

– Born vs. Me
Jan 14 at 12:38













That information helps a lot. So you want all files created in that folder and below to have 0755? I can't think of an easy way to do that. You could run an Cronjob every minute setting all files in that directory to 755 with chmod. Would that do the trick?

– Patient32Bit
Jan 14 at 12:43







That information helps a lot. So you want all files created in that folder and below to have 0755? I can't think of an easy way to do that. You could run an Cronjob every minute setting all files in that directory to 755 with chmod. Would that do the trick?

– Patient32Bit
Jan 14 at 12:43






1




1





@Patient32Bit umask 0775 will not set 775 permissions to a file. 0022 wil set 644 to a file and 755 for a directory. I think umask 0775 wil set 001 for files and 002 for directories. Read this cyberciti.biz/tips/….

– nobody
Jan 14 at 12:56







@Patient32Bit umask 0775 will not set 775 permissions to a file. 0022 wil set 644 to a file and 755 for a directory. I think umask 0775 wil set 001 for files and 002 for directories. Read this cyberciti.biz/tips/….

– nobody
Jan 14 at 12:56




















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.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1109617%2fubuntu-set-permissions-for-future-created-files%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

flock() on closed filehandle LOCK_FILE at /usr/bin/apt-mirror

Mangá

 ⁒  ․,‪⁊‑⁙ ⁖, ⁇‒※‌, †,⁖‗‌⁝    ‾‸⁘,‖⁔⁣,⁂‾
”‑,‥–,‬ ,⁀‹⁋‴⁑ ‒ ,‴⁋”‼ ⁨,‷⁔„ ‰′,‐‚ ‥‡‎“‷⁃⁨⁅⁣,⁔
⁇‘⁔⁡⁏⁌⁡‿‶‏⁨ ⁣⁕⁖⁨⁩⁥‽⁀  ‴‬⁜‟ ⁃‣‧⁕‮ …‍⁨‴ ⁩,⁚⁖‫ ,‵ ⁀,‮⁝‣‣ ⁑  ⁂– ․, ‾‽ ‏⁁“⁗‸ ‾… ‹‡⁌⁎‸‘ ‡⁏⁌‪ ‵⁛ ‎⁨ ―⁦⁤⁄⁕