How to chmod files and dirctories via SSH

WebTrooper

New Member
Hi all, great forum you have going here. Can someone please help me out with this? I know how to chmod via SSH. What I need to know is how to chmod a directory and all it's subdirectories to 0777 and chmod all files to 0644.

I'm using SSH Secure Shell client and writing to a centos box. Thanks! :)
 

WebTrooper

New Member
Thanks jnjc, but how do I chmod only the files, or only the subdirectories? -R is just recursive everything.

I think what I need is something like...

chmod 0777 -R Directories Only
chmod 0644 -R Files Only
 
Last edited:

jnjc

New Member
What you are describing is actually a bit tricky. One way you could do it is:

chmod 0644 -R *

which will change all files and directories.
Then use something like this:

du | awk '{print "chmod 0644 " $2}' | sh -v

which will change all directories. Do the commands in this order and it should do what you want (that said you might want to test it out before you do it on a production box).
 
Top