{"id":9369,"date":"2021-01-07T04:58:46","date_gmt":"2021-01-07T09:58:46","guid":{"rendered":"http:\/\/local.brightwhiz\/?p=9369"},"modified":"2021-12-04T06:31:38","modified_gmt":"2021-12-04T06:31:38","slug":"bulk-set-permissions-directories-755-files-644","status":"publish","type":"post","link":"http:\/\/local.brightwhiz\/bulk-set-permissions-directories-755-files-644\/","title":{"rendered":"How to Bulk set Permissions of Directories to 755 and Files to 644"},"content":{"rendered":"\n

This guide will show you how to set permissions of all directories to 755 and all files to 644 in your web application for better security.<\/p>\n\n\n\n

If you are not quite familiar with file or directory permissions then start by reading this article about chmod commands<\/a>. There we explain how to set the required permissions on any Linux<\/a> system. The article also explains what permissions 755 and 644 grant.<\/p>\n\n\n\n

It is always advised to keep the file and directory permissions to minimal. As a general practice, many web application frameworks suggest that developers maintain permissions for all directories at 755 and all files at 644.<\/p>\n\n\n\n

You may find that your web application has hundreds of files if not thousands and dozens of directories. It would be a nightmare to try and set the permissions of each file and directory individually.<\/p>\n\n\n\n

The good news is there is a better way.<\/p>\n\n\n\n

How to Set Permissions Recursively<\/h2>\n\n\n\n

Navigate to the directory with the cd<\/strong><\/em> command to get to the desired location under which you need to change the permissions. Such as:<\/p>\n\n\n\n

$ \/var\/www\/html<\/code><\/pre>\n\n\n\n

We will then run two commands. The first will find all directories in the path and change their permissions to 755 and the second will find all files and change their permissions to 644.<\/p>\n\n\n\n

$ find . -type d -exec chmod 755 {} +\n$ find . -type f -exec chmod 644 {} +<\/code><\/pre>\n\n\n\n

You can also add the -name directive to change a specific file type. This example shows how to set permissions for only PHP<\/a> files:<\/p>\n\n\n\n

$ find . -type f -name "*.php" -exec chmod 644 {} +<\/code><\/pre>\n\n\n\n

With that, you should be more efficient when changing file permissions.<\/p>\n","protected":false},"excerpt":{"rendered":"

This guide will show you how to set permissions of all directories to 755 and all files to 644 in your web application for better security. If you are not…<\/p>\n","protected":false},"author":1,"featured_media":9370,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,23,9,16],"tags":[121,183,313,354,424,433,526,598,604],"yoast_head":"\nHow to Bulk set Permissions of Directories to 755 and Files to 644<\/title>\n<meta name=\"description\" content=\"This guide will show you how to set permissions of all directories to 755 and all files to 644 in your web application for better security\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"http:\/\/local.brightwhiz\/bulk-set-permissions-directories-755-files-644\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Bulk set Permissions of Directories to 755 and Files to 644\" \/>\n<meta property=\"og:description\" content=\"This guide will show you how to set permissions of all directories to 755 and all files to 644 in your web application for better security\" \/>\n<meta property=\"og:url\" content=\"http:\/\/local.brightwhiz\/bulk-set-permissions-directories-755-files-644\/\" \/>\n<meta property=\"og:site_name\" content=\"Brightwhiz.com\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/brightwhiz\/\" \/>\n<meta property=\"article:published_time\" content=\"2021-01-07T09:58:46+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-12-04T06:31:38+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/local.brightwhiz\/wp-content\/uploads\/2021\/01\/chmod-bulk.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"630\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Michael Bright\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@brightwhizmag\" \/>\n<meta name=\"twitter:site\" content=\"@brightwhizmag\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Michael Bright\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"http:\/\/local.brightwhiz\/bulk-set-permissions-directories-755-files-644\/#article\",\"isPartOf\":{\"@id\":\"http:\/\/local.brightwhiz\/bulk-set-permissions-directories-755-files-644\/\"},\"author\":{\"name\":\"Michael Bright\",\"@id\":\"http:\/\/local.brightwhiz\/#\/schema\/person\/81f0f3126f13834ae2e7f381b3028e32\"},\"headline\":\"How to Bulk set Permissions of Directories to 755 and Files to 644\",\"datePublished\":\"2021-01-07T09:58:46+00:00\",\"dateModified\":\"2021-12-04T06:31:38+00:00\",\"mainEntityOfPage\":{\"@id\":\"http:\/\/local.brightwhiz\/bulk-set-permissions-directories-755-files-644\/\"},\"wordCount\":250,\"publisher\":{\"@id\":\"http:\/\/local.brightwhiz\/#organization\"},\"image\":{\"@id\":\"http:\/\/local.brightwhiz\/bulk-set-permissions-directories-755-files-644\/#primaryimage\"},\"thumbnailUrl\":\"http:\/\/local.brightwhiz\/wp-content\/uploads\/2021\/01\/chmod-bulk.jpg\",\"keywords\":[\"CentOS\",\"Debian\",\"InfoSec\",\"Linux\",\"Open Source\",\"Optimization\",\"Security\",\"Ubuntu\",\"Unix\"],\"articleSection\":[\"Articles\",\"Guides\",\"How To\",\"Technology\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"http:\/\/local.brightwhiz\/bulk-set-permissions-directories-755-files-644\/\",\"url\":\"http:\/\/local.brightwhiz\/bulk-set-permissions-directories-755-files-644\/\",\"name\":\"How to Bulk set Permissions of Directories to 755 and Files to 644\",\"isPartOf\":{\"@id\":\"http:\/\/local.brightwhiz\/#website\"},\"primaryImageOfPage\":{\"@id\":\"http:\/\/local.brightwhiz\/bulk-set-permissions-directories-755-files-644\/#primaryimage\"},\"image\":{\"@id\":\"http:\/\/local.brightwhiz\/bulk-set-permissions-directories-755-files-644\/#primaryimage\"},\"thumbnailUrl\":\"http:\/\/local.brightwhiz\/wp-content\/uploads\/2021\/01\/chmod-bulk.jpg\",\"datePublished\":\"2021-01-07T09:58:46+00:00\",\"dateModified\":\"2021-12-04T06:31:38+00:00\",\"description\":\"This guide will show you how to set permissions of all directories to 755 and all files to 644 in your web application for better security\",\"breadcrumb\":{\"@id\":\"http:\/\/local.brightwhiz\/bulk-set-permissions-directories-755-files-644\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\/\/local.brightwhiz\/bulk-set-permissions-directories-755-files-644\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/local.brightwhiz\/bulk-set-permissions-directories-755-files-644\/#primaryimage\",\"url\":\"http:\/\/local.brightwhiz\/wp-content\/uploads\/2021\/01\/chmod-bulk.jpg\",\"contentUrl\":\"http:\/\/local.brightwhiz\/wp-content\/uploads\/2021\/01\/chmod-bulk.jpg\",\"width\":1200,\"height\":630,\"caption\":\"Set Permissions bulk chmod\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\/\/local.brightwhiz\/bulk-set-permissions-directories-755-files-644\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"http:\/\/local.brightwhiz\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Bulk set Permissions of Directories to 755 and Files to 644\"}]},{\"@type\":\"WebSite\",\"@id\":\"http:\/\/local.brightwhiz\/#website\",\"url\":\"http:\/\/local.brightwhiz\/\",\"name\":\"Brightwhiz.com\",\"description\":\"Best Tech guides, Tutorials, and News\",\"publisher\":{\"@id\":\"http:\/\/local.brightwhiz\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\/\/local.brightwhiz\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"http:\/\/local.brightwhiz\/#organization\",\"name\":\"Brightwhiz\",\"url\":\"http:\/\/local.brightwhiz\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/local.brightwhiz\/#\/schema\/logo\/image\/\",\"url\":\"http:\/\/local.brightwhiz\/wp-content\/uploads\/2021\/11\/brightwhiz-com-logo-orange.png\",\"contentUrl\":\"http:\/\/local.brightwhiz\/wp-content\/uploads\/2021\/11\/brightwhiz-com-logo-orange.png\",\"width\":706,\"height\":135,\"caption\":\"Brightwhiz\"},\"image\":{\"@id\":\"http:\/\/local.brightwhiz\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/brightwhiz\/\",\"https:\/\/x.com\/brightwhizmag\",\"https:\/\/instagram.com\/bright_whiz\/\",\"https:\/\/www.pinterest.com\/sobbayi\/\",\"https:\/\/www.youtube.com\/channel\/UC6sCdP_d_RiTIM7ErFT-PSQ\"]},{\"@type\":\"Person\",\"@id\":\"http:\/\/local.brightwhiz\/#\/schema\/person\/81f0f3126f13834ae2e7f381b3028e32\",\"name\":\"Michael Bright\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/local.brightwhiz\/#\/schema\/person\/image\/\",\"url\":\"http:\/\/1.gravatar.com\/avatar\/da90485875ff0aafa38fdd494abe87d1?s=96&d=mm&r=g\",\"contentUrl\":\"http:\/\/1.gravatar.com\/avatar\/da90485875ff0aafa38fdd494abe87d1?s=96&d=mm&r=g\",\"caption\":\"Michael Bright\"},\"sameAs\":[\"https:\/\/sobbayi.com\"],\"url\":\"http:\/\/local.brightwhiz\/author\/sobbayiadmin\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Bulk set Permissions of Directories to 755 and Files to 644","description":"This guide will show you how to set permissions of all directories to 755 and all files to 644 in your web application for better security","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"http:\/\/local.brightwhiz\/bulk-set-permissions-directories-755-files-644\/","og_locale":"en_US","og_type":"article","og_title":"How to Bulk set Permissions of Directories to 755 and Files to 644","og_description":"This guide will show you how to set permissions of all directories to 755 and all files to 644 in your web application for better security","og_url":"http:\/\/local.brightwhiz\/bulk-set-permissions-directories-755-files-644\/","og_site_name":"Brightwhiz.com","article_publisher":"https:\/\/www.facebook.com\/brightwhiz\/","article_published_time":"2021-01-07T09:58:46+00:00","article_modified_time":"2021-12-04T06:31:38+00:00","og_image":[{"width":1200,"height":630,"url":"http:\/\/local.brightwhiz\/wp-content\/uploads\/2021\/01\/chmod-bulk.jpg","type":"image\/jpeg"}],"author":"Michael Bright","twitter_card":"summary_large_image","twitter_creator":"@brightwhizmag","twitter_site":"@brightwhizmag","twitter_misc":{"Written by":"Michael Bright","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"http:\/\/local.brightwhiz\/bulk-set-permissions-directories-755-files-644\/#article","isPartOf":{"@id":"http:\/\/local.brightwhiz\/bulk-set-permissions-directories-755-files-644\/"},"author":{"name":"Michael Bright","@id":"http:\/\/local.brightwhiz\/#\/schema\/person\/81f0f3126f13834ae2e7f381b3028e32"},"headline":"How to Bulk set Permissions of Directories to 755 and Files to 644","datePublished":"2021-01-07T09:58:46+00:00","dateModified":"2021-12-04T06:31:38+00:00","mainEntityOfPage":{"@id":"http:\/\/local.brightwhiz\/bulk-set-permissions-directories-755-files-644\/"},"wordCount":250,"publisher":{"@id":"http:\/\/local.brightwhiz\/#organization"},"image":{"@id":"http:\/\/local.brightwhiz\/bulk-set-permissions-directories-755-files-644\/#primaryimage"},"thumbnailUrl":"http:\/\/local.brightwhiz\/wp-content\/uploads\/2021\/01\/chmod-bulk.jpg","keywords":["CentOS","Debian","InfoSec","Linux","Open Source","Optimization","Security","Ubuntu","Unix"],"articleSection":["Articles","Guides","How To","Technology"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"http:\/\/local.brightwhiz\/bulk-set-permissions-directories-755-files-644\/","url":"http:\/\/local.brightwhiz\/bulk-set-permissions-directories-755-files-644\/","name":"How to Bulk set Permissions of Directories to 755 and Files to 644","isPartOf":{"@id":"http:\/\/local.brightwhiz\/#website"},"primaryImageOfPage":{"@id":"http:\/\/local.brightwhiz\/bulk-set-permissions-directories-755-files-644\/#primaryimage"},"image":{"@id":"http:\/\/local.brightwhiz\/bulk-set-permissions-directories-755-files-644\/#primaryimage"},"thumbnailUrl":"http:\/\/local.brightwhiz\/wp-content\/uploads\/2021\/01\/chmod-bulk.jpg","datePublished":"2021-01-07T09:58:46+00:00","dateModified":"2021-12-04T06:31:38+00:00","description":"This guide will show you how to set permissions of all directories to 755 and all files to 644 in your web application for better security","breadcrumb":{"@id":"http:\/\/local.brightwhiz\/bulk-set-permissions-directories-755-files-644\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["http:\/\/local.brightwhiz\/bulk-set-permissions-directories-755-files-644\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/local.brightwhiz\/bulk-set-permissions-directories-755-files-644\/#primaryimage","url":"http:\/\/local.brightwhiz\/wp-content\/uploads\/2021\/01\/chmod-bulk.jpg","contentUrl":"http:\/\/local.brightwhiz\/wp-content\/uploads\/2021\/01\/chmod-bulk.jpg","width":1200,"height":630,"caption":"Set Permissions bulk chmod"},{"@type":"BreadcrumbList","@id":"http:\/\/local.brightwhiz\/bulk-set-permissions-directories-755-files-644\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"http:\/\/local.brightwhiz\/"},{"@type":"ListItem","position":2,"name":"How to Bulk set Permissions of Directories to 755 and Files to 644"}]},{"@type":"WebSite","@id":"http:\/\/local.brightwhiz\/#website","url":"http:\/\/local.brightwhiz\/","name":"Brightwhiz.com","description":"Best Tech guides, Tutorials, and News","publisher":{"@id":"http:\/\/local.brightwhiz\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/local.brightwhiz\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"http:\/\/local.brightwhiz\/#organization","name":"Brightwhiz","url":"http:\/\/local.brightwhiz\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/local.brightwhiz\/#\/schema\/logo\/image\/","url":"http:\/\/local.brightwhiz\/wp-content\/uploads\/2021\/11\/brightwhiz-com-logo-orange.png","contentUrl":"http:\/\/local.brightwhiz\/wp-content\/uploads\/2021\/11\/brightwhiz-com-logo-orange.png","width":706,"height":135,"caption":"Brightwhiz"},"image":{"@id":"http:\/\/local.brightwhiz\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/brightwhiz\/","https:\/\/x.com\/brightwhizmag","https:\/\/instagram.com\/bright_whiz\/","https:\/\/www.pinterest.com\/sobbayi\/","https:\/\/www.youtube.com\/channel\/UC6sCdP_d_RiTIM7ErFT-PSQ"]},{"@type":"Person","@id":"http:\/\/local.brightwhiz\/#\/schema\/person\/81f0f3126f13834ae2e7f381b3028e32","name":"Michael Bright","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/local.brightwhiz\/#\/schema\/person\/image\/","url":"http:\/\/1.gravatar.com\/avatar\/da90485875ff0aafa38fdd494abe87d1?s=96&d=mm&r=g","contentUrl":"http:\/\/1.gravatar.com\/avatar\/da90485875ff0aafa38fdd494abe87d1?s=96&d=mm&r=g","caption":"Michael Bright"},"sameAs":["https:\/\/sobbayi.com"],"url":"http:\/\/local.brightwhiz\/author\/sobbayiadmin\/"}]}},"_links":{"self":[{"href":"http:\/\/local.brightwhiz\/wp-json\/wp\/v2\/posts\/9369"}],"collection":[{"href":"http:\/\/local.brightwhiz\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/local.brightwhiz\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/local.brightwhiz\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/local.brightwhiz\/wp-json\/wp\/v2\/comments?post=9369"}],"version-history":[{"count":0,"href":"http:\/\/local.brightwhiz\/wp-json\/wp\/v2\/posts\/9369\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/local.brightwhiz\/wp-json\/wp\/v2\/media\/9370"}],"wp:attachment":[{"href":"http:\/\/local.brightwhiz\/wp-json\/wp\/v2\/media?parent=9369"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/local.brightwhiz\/wp-json\/wp\/v2\/categories?post=9369"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/local.brightwhiz\/wp-json\/wp\/v2\/tags?post=9369"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}