link Updating permissions on all files and directories within a directory← Back

I extracted a tarball which had applied 777 (rwx) permissions to all files and directories that it contained. I wanted to set all files to 644 and all directories to 755, but there were too many levels to do it manually so I needed to do it through a shell script. After trying various BASH “for” loops, I checked the man page for “find” and was able to do the whole lot in 2 lines:

find . * -type d -exec chmod 0755 {} +
find . * -type f -exec chmod 0644 {} +


There are no comments

Post a comment