Find and Change File Permissions Recursively, Linux / UNIX

To find all files in /home/user/demo directory, enter:

$ find /home/user/demo -type f -print

To find all files in /home/user/demo directory with permission 777, enter:

$ find /home/user/demo -type f -perm 777 -print

Finally, apply new permission using the -exec option as follows:

$ find /home/user/demo -type f -perm 777 -print -exec chmod 755 {} \;

To select directories and subdirectories use the following syntax:

$ find /home/user/demo -type d -perm 777 -print -exec chmod 755 {} \;

Related Posts

Comments are closed.