Change file and folder permissions

  1. find . -type f -exec chmod 644 {} ;
  2. find . -type d -exec chmod 755 {} ;

    below works for ubuntu
    To change permission of only files under a specified directory.
    [email protected]:/home/user$ sudo find /path/to/someDirectory -type f -print0 | xargs -0 sudo chmod 644

  3. [email protected]:/home/user$ ls -l
  4. total 3
  5. -rw-r–r–  1 user user 0 Nov 19 20:13 file1
  6. drwxrwxrwx  2 user user 4096 Nov 19 20:13 folder
  7. -rw-r–r–  1 user user 0 Nov 19 20:13 file2
    To change permission of only directories under a specified directory (including that directory):
    [email protected]:/home/user$ sudo find /path/to/someDirectory -type d -print0 | xargs -0 sudo chmod 755
  8. [email protected]:/home/user$ ls -l
  9. total 3
  10. -rw-r–r–  1 user user 0 Nov 19 20:13 file1
  11. drwxr-xr-x  2 user user 4096 Nov 19 20:13 folder
  12. -rw-r–r–  1 user user 0 Nov 19 20:13 file2

Leave a Reply