POSIX https://www.hexblot.com/ en Recursively changing permissions https://www.hexblot.com/console-tips/recursively-changing-permissions <span class="field field--name-title field--type-string field--label-hidden">Recursively changing permissions</span> <div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><p>There are times when your website's filesystem permissions get screwed. There's no other way to put it -- some directories are not writeable, some are not ... ARGH! The worst part is that you need to apply different permissions on files and directories, to prevent security issues.</p> <p><!--break--></p> <p>Here are two simple one-liners that do exactly that:</p> <p>For files, you only need to make them world-readable, and writeable by your user/group</p> <pre class="typo-code"> # find /var/www/mysite-dir -type f -exec chmod 664 {} \; </pre> <p>The above command will recursively apply read/write permissions to all files for the owner and group, and only read for everyone else.</p> <p>For directories, you also need to include the execute bit, otherwise you won't be able to enter into the directory:</p> <pre class="typo-code"> # find /var/www/mysite-dir -type d -exec chmod 775 {} \; </pre> <p>The above command will recursively apply read/write/execute permissions to all directories for the owner and group, and only the read and execute for everyone else.</p> <p>Finally, if you collaborate with others, it may be beneficial to make group permissiosn sticky so that when they create files they don't have them all to themselves:</p> <pre class="typo-code"> # find /var/www/mysite-dir -type d -exec chmod g+s {} \; </pre> <p>The above command will make it so that new files maintain the parent folder's group permissions (ie writeable from group).</p> </div> <span class="field field--name-uid field--type-entity-reference field--label-hidden"><span lang="" about="/users/nand" typeof="schema:Person" property="schema:name" datatype="">nand</span></span> <span class="field field--name-created field--type-created field--label-hidden">Tue, 04/02/2013 - 16:13</span> <div class="field field--name-taxonomy-vocabulary-2 field--type-entity-reference field--label-above field--entity-reference-target-type-taxonomy-term clearfix"> <h3 class="field__label">Tags</h3> <ul class='links field__items'> <li><a href="/category/tags/linux" hreflang="en">Linux</a></li> <li><a href="/category/tags/console" hreflang="en">Console</a></li> <li><a href="/category/tags/filesystem" hreflang="en">filesystem</a></li> <li><a href="/category/tags/posix" hreflang="en">POSIX</a></li> <li><a href="/category/tags/permissions" hreflang="en">permissions</a></li> <li><a href="/category/tags/find" hreflang="en">find</a></li> </ul> </div> Tue, 02 Apr 2013 13:13:06 +0000 nand 145 at https://www.hexblot.com