Skip to content

Instantly share code, notes, and snippets.

@lysender
Last active August 14, 2023 08:25
Show Gist options
  • Save lysender/965ccd03fb5b8336a745d8662dfc2e81 to your computer and use it in GitHub Desktop.
Save lysender/965ccd03fb5b8336a745d8662dfc2e81 to your computer and use it in GitHub Desktop.
Linux find and exec

Change permissions of all files in a directory including files inside sub-directories

I wanted to ensure that all files has the 644 permissions but I don't want the directories to have the same permissions.

First, I'll run it with ls -l command to avoid accidental command execution.

find ./ -type f -name "*" -exec ls -l "{}" \;

Once confirmed that it finds the correct files, I can run the chmod command.

find ./ -type f -name "*" -exec chmod 644 "{}" \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment