Need to fix file permissions in a user's home directory

Solution 1:

This should do the trick:

find /home/user -type d -print0 | xargs -0 chmod 0775
find /home/user -type f -print0 | xargs -0 chmod 0664

Solution 2:

find can do the trick alone with -exec:

find /home/user -type f -exec chmod 0664 {} \;
find /home/user -type d -exec chmod 0775 {} \;

to prevent find from spawning a chmod for each entry:

find /home/user -type f -exec chmod 0664 {} +
find /home/user -type d -exec chmod 0775 {} +

(this effectively calls chmod once with the list of all files as parameters rather than one chmod per file)


Solution 3:

This answer won't solve your problem, but someone might find it useful for a similar problem where files have less permission than they should do.

# chmod -R . u=rwX,g=rX,o=rX

The magic is the X permission, rather than x. The chmod manpage describes it thus:

execute/search only if the file is a directory or already has execute permission for some user

This isn't suitable in your case as your files have execute permission so, will match the second test.