How can I change folder and file permissions for all files and folders recursively inside current directory? I am not sure, why, but my command fails with this

output: chmod: missing operand after '644./components/path/path/path'

My command is:

find . * -type d -exec chmod 755{} \;

As user pdo pointed, I want change folder permissions to 755-


You're missing a space after 644.

Also, 644 is probably not what you want on a directory. You probably want 755.

Edit to include answer from comments below:

For directories:

find . -type d -exec chmod 755 {} \;

For files:

find . -type f -exec chmod 644 {} \;

There's very likely other ways (maybe shorter) to do this, but this will work.

  • Yes, I want to 755. Now I got find: '.', '*' .Permission denied, and failed to restore initial working directory.
    – Alan Kis
    Jan 8 '16 at 20:31
  • What are the permissions on the current working directory?
    – pdo
    Jan 8 '16 at 20:32
  • Prefix the command with sudo and it should work if you have permission to do so. Jan 8 '16 at 20:32
  • You mgiht want to add this (or something like it) to your answer to make your suggestion explicit: find . -type d -exec chmod 755 {} +
    – roaima
    Jan 8 '16 at 20:35
  • @pdo, current working directory is 750. I am not root, this is jailed cPanel shell.
    – Alan Kis
    Jan 8 '16 at 20:37

Another way to do this is:

chmod -R u=rwX,g=rX,o=rX /path/to/dir

The capital X is a conditional execute- if the file is a directory the execute bit gets added OR if the file is already executable the execute bit gets retained.

Though this would add permissions to non directory files. If these permissions are acceptable, this works for quickly adding access to folders.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.