Mithun Sreedharan Mithun Sreedharan - 3 months ago 9
Linux Question

Setting file permission for Files and Directories

I need to apply below permission policies to my files under

www
folder

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?

Answer

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.