2

I have a lot of files in one specific folder, and I want to change the permissions only for files and only in this folder (not subfolders), how can I achieve this? Thanks in advance.

1 Answer 1

6
find your_folder -type f -exec chmod your_permissions {} \;

This command changes the permissions only for regular files in the selected folder (replace "your_folder" and "your_permissions" with the appropriate values).

If you only want to change the permissions for files in your_folder itself and not in its subfolders you can add -maxdepth:

find your_folder -maxdepth 1 -type f -exec chmod your_permissions {} \;
9
  • what means "{} \" at the end?
    – lpFranz
    May 24, 2018 at 13:04
  • Ok you beat me to it :) have an upvote.
    – Videonauth
    May 24, 2018 at 13:04
  • @lpFranz {} stands for what find has found.
    – muclux
    May 24, 2018 at 13:05
  • @lpFranz {} tells find to insert the find results into the formula, the `` in front of the semicolon is just an escape character.
    – Videonauth
    May 24, 2018 at 13:06
  • chmod g+r *.* -> The "*.*" do the same thing? I've received this tip.
    – lpFranz
    May 24, 2018 at 13:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .