Mithun Sreedharan Mithun Sreedharan - 2 months ago 7
Linux Question

Setting file permission for Files and Directories

I need to apply below permission policies to my files under


664 to all files in www recursively,
755 to all directories under www recursively

I tried

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

But always getting error

find: missing argument to `-exec'

What is the solution?


Backslash before semi-colon (or quotes around it):

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

The shell sees the semi-colon you typed as the end of the command and does not pass it to find, which then complains that it is missing.