Unix Trickery Explained

find . -type d -exec chmod 755 {} find . -type f -exec chmod 644 {}
find is a shell program built into OS X and most if not all Unix based systems. If you type 'man find' in the terminal it will tell you all the info about the switches you can use with find. You'll notice that there are many ways to search for things, including by name, type, permissions, etc. Find also allows you to execute programs on its results using the -exec switch.
chmod is program that allows you to set permissions on files and directories. Alternatively you can set permissions using 'Command + I' and looking under 'Ownership and Permissions'. This doesn't allow you to change a bunch multiple file permissions at once,

In the command 'find . -type f -exec chmod 644 {}' the 6 corresponds to the first set of 'rwx', the middle 4 corresponds to the second set of 'rwx' and the last 4 corresponds to the last set of 'rwx'. The numbers 644 correspond to binary bits, x=1, w=2, r=4. The 6 stands for rw- (read=4 + write=2). So the user has read and write permissions on the file. The 4 stands for r-- (read=4). So if amazingly you are still following me 644 means user has read and write permissions, and group and world have read permission. Heres a rundown of each possibility.
7 = rwx (read write execute)
6 = rw- (read write)
5 = r-x (read execute)
4 = r-- (read)
3 = -wx (write execute)
2 = -w- (write)
1 = --x (execute)
0 = --- (no permissions)

0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home