Chmod Files and Folders Differentially

I am sure you have had situations where all the files and folders in a subdirectory are accidentally changed to the wrong permissions.

Basic permissions of the files on a website, so visitors can interact: 644

== Files can be read but nobody is allowed to write (edit) the files but the owner.

Owner | Group | Others
R W –  | R – –   | R  –  – ====

R=Read, W=Write, X=eXecute

To get the octal permission number (i.e.644) which is additive

R=4, W=2, X=1 (“-” also means zero)

So the Owner can Read and Write (4+2+0=6)

_____ Group can Read _______ (4+0+0=4)

____ Others can Read _______ (4+0+0=4)

Basic permissions of the subdirectories on a website, so visitors can interact: 755

== Directories can be executed (opened) nobody is allowed to write (edit) the directories except the Owner

Owner | Group | Others
R W X  | R – X   | R – X

R=Read, W=Write, X=eXecute

To get the octal permission number (i.e.644) which is additive

R=4, W=2, X=1 (“-” also means zero)

So the Owner can Read, Write and eXecute (Open) (4+2+1=7)

_____ Group can Read, ____ and eXecute (Open) (4+0+1=5)

_____ Others can Read, ___ and eXecute (Open) (4+0+1=5)

How??

In the command line, as the owning user:

find /path/to/base/dir -type d -exec chmod 755 {} +

and

find /path/to/base/dir -type f -exec chmod 644 {} +