Last active
November 12, 2015 18:30
-
-
Save liggitt/78423251cfbe6b1aca97 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
mkdir -p 0-rwx-/1000-rwx-/2000-rwx-/0-rw-/1000-rw-/2000-rw-/0-r-/1000-r-/2000-r-/0--/1000--/2000--/x | |
mkdir -p 0--rwx/1000--rwx/2000--rwx/0--rw/1000--rw/2000--rw/0--r/1000--r/2000--r/0--/1000--/2000--/x | |
# create a file in each dir | |
find . -type d | xargs -n 1 bash -c 'touch "$@"/myfile' {} | |
# owned by some user/group | |
find . -name myfile | xargs chown 3000 | |
find . -name myfile | xargs chgrp 3000 | |
# with no permissions at all | |
find . -name myfile | xargs chmod a= | |
# change owner | |
find . -name "0-*" | xargs chown 0 | |
find . -name "1000-*" | xargs chown 1000 | |
find . -name "2000-*" | xargs chown 2000 | |
# change group | |
find . -name "0-*" | xargs chgrp 0 | |
find . -name "1000-*" | xargs chgrp 1000 | |
find . -name "2000-*" | xargs chgrp 2000 | |
# change user permissions | |
find . -name "*--*" | xargs chmod u= | |
find . -name "*-r-*" | xargs chmod u=r | |
find . -name "*-rw-*" | xargs chmod u=rw | |
find . -name "*-rwx-*" | xargs chmod u=rwx | |
# change group permissions | |
find . -name "*-" | xargs chmod g= | |
find . -name "*-r" | xargs chmod g=r | |
find . -name "*-rw" | xargs chmod g=rw | |
find . -name "*-rwx" | xargs chmod g=rwx | |
# remove all other permissions | |
chmod -R o= . |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@deads2k, it does: