Linux / UNIX: Change File Permissions Recursively ( conditional )

Linux / UNIX: Change File Permissions Recursively ( conditional )

To change file permissions recursively on a Linux or Unix system, you can use the find command with the -exec option.

Here's an example of how to use the find command to change file permissions recursively:

find /path/to/directory -type f -exec chmod 644 {} \;
Sourc‮:e‬www.lautturi.com

This command will find all files under the /path/to/directory directory and its subdirectories, and change their permissions to 644.

You can also use the find command with the -exec option to change file permissions recursively based on certain conditions.

For example, to change the file permissions of all files with the .txt extension to 644 under the /path/to/directory directory and its subdirectories, you can use the following command:

find /path/to/directory -type f -name "*.txt" -exec chmod 644 {} \;
Created Time:2017-10-29 22:08:56  Author:lautturi