-->



Unix Trickery Explained

Aldactone For Sale Cystone No Prescription Buy Levlen No Prescription Buy Online Colchicine Buy Epivir-hbv Online Detrol For Sale Myambutol No Prescription Buy Exelon No Prescription Buy Online Glucophage Buy Nolvadex Online Cardizem For Sale Augmentin No Prescription Buy Plan B No Prescription Buy Online Imitrex Buy Lisinopril Online Lotensin For Sale Hgh No Prescription Buy Phentrimine No Prescription Buy Online Acticin Buy Lopressor Online Ayurslim For Sale Naprosyn No Prescription Buy Azulfidine No Prescription Buy Online Diarex Buy Prograf Online
Powered by Gregarious (39)

I realized this morning that I should probably provide a bit of explanation about the Unix commands that I used yesterday.

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, so thats why chmod is useful. chmod is a bit confusing to explain but I’ll do my best. To use chmod effectively you need to understand how it works. The numbers after the command set the permissions. To illustrate this open up the terminal and type ‘ls -l’ This will list all the files in the directory and information about them. The first column is the permissions on the files. You’ll notice they are in the format ‘drwxrwxrwx’. R stands for read, W denotes write, and X means execute. The first set of ‘rwx’ is the users permissions, the second set is the users group, and the final set is the world (ie anyone).

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)

If you’ve made it this far I’ve got a treat for you! Do you ever want to open a terminal that is already at the directory that you are currently at in the finder? I do. I can’t stand having to cd all the way to a directory (or type the full path) to execute a command on a file. If you download and install Open Terminal Here you won’t have to.

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Reddit
  • Technorati
  • NewsVine
  • Furl

1 Response to “Unix Trickery Explained”


  1. Gravatar Icon 1 Paul Zovighian Apr 13th, 2007 at 7:57 am

    Thanks, this helped a lot :)

Leave a Comment


Please Note: If this is your first time commenting, your comment is subject to moderation. There is no need to resubmit your comment.




heat pumps and best buy pirodr! 666

Close
E-mail It
Socialized through Gregarious 39