title: Chown and chmod for a big number of files
body: <p>The server is Apache and a bunch of folders with root privileges ~ 1 200 000 folders in each file to 1. Everything is on <em>Amazon aws</em>, <em>linux ubuntu</em>. Since the disc itself has 22Gb, the number of files stored in the memory unit was increased. The file system is <code>ext4</code>, <code>inode_ratio = 4096</code>, which makes it possible to store 22GB ~ 6,000,000 inode.</p>
  
  <p><strong>The problem: everyone needs 2.4 million files to chown www-data.www-data and chmod 0755</strong></p>
  
  <p>I'm doing: <code>sudo chown www-data.www-data -R dir /</code>
  eventually runs about 15 minutes and can be established only to the owner of 600,000 files, and does not go beyond.</p>
  
  <p>Searched in an Internet, I found a <code>xargs -p</code> and <code>find</code>. I can not assemble them, tell me who knows how to set <code>chown</code> only those files who are now under the same root and <code>chmod 0755</code> for those files that do not have it. Something like this</p>
  
  <pre><code>find -rights -rw-r--r-- dir/ | xargs -p chmod 0755 -R dir/ 
  </code></pre>
  
  <p>Thanks for any help</p>