Recursive chmod only on {directories|files}

6

1

I'd like to know how could I change the permissions of all my folders recursively under a path (e.g. /Users/me/Desktop/main_folder) and also change permissions to all my files under a specific folder.

These are the permissions I'd like to assign:

  • All folders: 700
  • All files: 600

There's a question for folders, but I didn't find one for the files.

Jonathan Solorzano

Posted 2015-12-19T23:00:29.617

Reputation: 179

Pls read my Edit URGENTLY – MariusMatutiae – 2015-12-19T23:33:44.840

Answers

7

That's

find . -type d -exec chmod 700 {} \;

for all directories begining from . the current directory, and

find . -type f -exec chmod 600 {} \;

for the files.

Is there a way to know all the folders modified?

That would be

find . -type d -exec chmod 700 {} \; -exec echo {} \;

I have to cd to the root folder first right?

PLEASE DO NOT DO THIS FROM THE ROOT DIRECTORY: you will make all executables un-excutable, including ls, rm, mkdir, and so on. The system will become unmanageable!!!

MariusMatutiae

Posted 2015-12-19T23:00:29.617

Reputation: 41 321

I have to cd to the root folder first right? – Jonathan Solorzano – 2015-12-19T23:08:39.687

Is there a way to know all the folders modified? – Jonathan Solorzano – 2015-12-19T23:09:06.473

Nou haha, when I said root folder, I meant the root of my app for example. – Jonathan Solorzano – 2015-12-19T23:43:40.263