{"id":192,"date":"2012-10-05T12:57:23","date_gmt":"2012-10-05T11:57:23","guid":{"rendered":"http:\/\/oprsteny.cz\/?p=192"},"modified":"2012-10-08T12:33:21","modified_gmt":"2012-10-08T11:33:21","slug":"recursively-chmod-only-directories-or-files","status":"publish","type":"post","link":"https:\/\/oprsteny.cz\/?p=192","title":{"rendered":"Recursively chmod only directories or files"},"content":{"rendered":"<p>Ever come across the problem of needing to chmod a directory and its many, many, sub-directories, but you don\u2019t want to touch any of the files? Maybe it\u2019s the exact opposite, or you need to recursively change the permissions on only files with a specific extension. Well I had a similar problem with my web server settings.<!--more--><\/p>\n<pre>find . -type d -exec chmod 755 {} \\;<\/pre>\n<ul>\n<li>This will \u201c<code>find<\/code>\u201d all directories, starting at \u201c<code>.<\/code>\u201c, and chmod them to\u00a0<code>755<\/code>.<\/li>\n<\/ul>\n<pre><code>find . -type f -exec chmod 644 {} \\;<\/code><\/pre>\n<ul>\n<li>This snippet does the opposite and finds only files. The difference (beside the file permissions) is the \u201c<code>-type f<\/code>\u201c, \u201c<code>f<\/code>\u201d specifies files and \u201c<code>d<\/code>\u201d directories.<\/li>\n<\/ul>\n<p>If you check the comments, you\u2019ll find a few additional snippets:<\/p>\n<pre><code>find . -type f -name '*.htm*' -exec chmod 644 {} \\;<\/code><\/pre>\n<ul>\n<li>This lets you \u201c<code>find<\/code>\u201d files (\u201c<code>-type f<\/code>\u201c) with a specific extension (\u201c<code>-name '*.htm*'<\/code>\u201c) and chmod them with your desired permission (\u201c<code>-exec chmod 644 {}<\/code>\u201c).<\/li>\n<\/ul>\n<pre><code>chmod -R o+rX<\/code><\/pre>\n<ul>\n<li>This snippet will recursively chmod \u201cother\u201d (\u201c<code>o<\/code>\u201c) permissions with read\/eXecutable (\u201c<code>+rX<\/code>\u201c), and the capital X ensures that directories and files set (user\/group permissions) to executable will be properly modified, while ignoring regular (non-executable) files.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Ever come across the problem of needing to chmod a directory and its many, many, sub-directories, but you don\u2019t want to touch any of the files? Maybe it\u2019s the exact opposite, or you need to recursively change the permissions on &hellip; <a href=\"https:\/\/oprsteny.cz\/?p=192\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[9,45],"tags":[],"class_list":["post-192","post","type-post","status-publish","format-standard","hentry","category-development","category-linux"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p3nYbe-36","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/oprsteny.cz\/index.php?rest_route=\/wp\/v2\/posts\/192","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/oprsteny.cz\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/oprsteny.cz\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=192"}],"version-history":[{"count":2,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=\/wp\/v2\/posts\/192\/revisions"}],"predecessor-version":[{"id":194,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=\/wp\/v2\/posts\/192\/revisions\/194"}],"wp:attachment":[{"href":"https:\/\/oprsteny.cz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=192"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=192"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=192"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}