{"id":3708,"date":"2023-04-18T17:10:29","date_gmt":"2023-04-18T17:10:29","guid":{"rendered":"https:\/\/qbytes.cloud\/?p=3708"},"modified":"2023-04-18T17:23:22","modified_gmt":"2023-04-18T17:23:22","slug":"change-permissions-using-find-command","status":"publish","type":"post","link":"https:\/\/www.qbytes.cloud\/index.php\/2023\/04\/18\/change-permissions-using-find-command\/","title":{"rendered":"Change permissions using find command"},"content":{"rendered":"\n<p>To change permissions using find command.<\/p>\n\n\n\n<p>On a Linux server, if you are in need of changing the permissions of a bulk amount of files or directories recursively, we can use the \u2018find\u2019 command to do it. The steps are explained below:<\/p>\n\n\n\n<p>Change to the directory in which you need to change the permissions.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\ncd \/home\/user\/public_html \n<\/pre><\/div>\n\n\n<p>Changing Files<\/p>\n\n\n\n<p>The permission changes are different based on the situation we are having. If you need to change the permissions of all files inside the directory to 644 recursively, please use the following: <\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nfind . -type f -exec chmod 644 {} \\;\n<\/pre><\/div>\n\n\n<p>You can specify a specific directory in the following way as well: <\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nfind \/home\/abc\/ -type f -exec chmod 644 {} \\;\n<\/pre><\/div>\n\n\n<p>Directories<\/p>\n\n\n\n<p>If you are looking to change the permissions of directories inside the current folder to 755, use the following:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nfind \/home\/abc\/ -type d -exec chmod 755 {} \\;\n<\/pre><\/div>\n\n\n<p>If you are looking to change the permissions of all files having 777 permissions only to 644, use the following: <\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nfind . -type f -perm 777 -exec chmod 644 {} \\;\n<\/pre><\/div>\n\n\n<p>Use the same format for directories by changing the option f: <\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nfind . -type d-perm 777 -exec chmod 755 {} \\;\n<\/pre><\/div>\n\n\n<p>You can also change permission using xargs command to do this quickly.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nfind . -type d -print0 | xargs -0 chmod 755\n<\/pre><\/div>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nfind . -type f -print0 | xargs -0 chmod 644\n<\/pre><\/div>","protected":false},"excerpt":{"rendered":"<p>To change permissions using find command. On a Linux server, if you are in need of changing the permissions of a bulk amount of files or directories recursively, we can use the \u2018find\u2019 command to do it. The steps are explained below: Change to the directory in which you need to change the permissions. Changing &#8230; <a title=\"Change permissions using find command\" class=\"read-more\" href=\"https:\/\/www.qbytes.cloud\/index.php\/2023\/04\/18\/change-permissions-using-find-command\/\" aria-label=\"Read more about Change permissions using find command\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-3708","post","type-post","status-publish","format-standard","hentry","category-administration"],"_links":{"self":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts\/3708","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/comments?post=3708"}],"version-history":[{"count":5,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts\/3708\/revisions"}],"predecessor-version":[{"id":3715,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts\/3708\/revisions\/3715"}],"wp:attachment":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/media?parent=3708"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/categories?post=3708"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/tags?post=3708"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}