Got a bunch of public directories you need to set permissions on?  Here ya go…

```

!/bin/bash

set the owner and group for these directories recursively

chown -R bill:noobs /pub/this

chown -R bill:noobs /pub/that

chown -R bill:noobs /pub/theotherthing

set perms for all sub-directories

find /pub/this -type d | xargs -d"\n" chmod 755

find /pub/that -type d | xargs -d"\n" chmod 755

find /pub/theotherthing -type d | xargs -d"\n" chmod 755

set perms for all files

find /pub/this -type f | xargs -d"\n" chmod 644

find /pub/that -type f | xargs -d"\n" chmod 644

find /pub/theotherthing -type f | xargs -d"\n" chmod 644```

755 = recurse dirs and read whats in them for group and other, owner can do whatever
644 = owner can read and write but not execute and all the rest can read.

Blog Logo

Mario Loria


Published

Image

./scriptthe.net

Because 127.0.0.1 gets old after a while.

Back to Overview