05.01.2013 Views

Mac OS X Leopard - ARCAism

Mac OS X Leopard - ARCAism

Mac OS X Leopard - ARCAism

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Each of the permissions are either r, w, or x, signifying the ability to read, write, or execute<br />

(these are often referred to as bits). In the case of a directory, the execute bit signifies the ability<br />

to open the directory. The owner of any file can set these permissions as they see fit using the<br />

chmod command. Additionally, the owner can reset the group the files belong to to any other<br />

group the owner belongs to using the chgrp command.<br />

The chmod command can be used one of two ways to set the permissions (also referred to as<br />

setting the mode), either literally or symbolically. The literal way is to specify the permissions as<br />

a string of numbers such as the following:<br />

chmod nnnn filename<br />

where nnnn is the combined value of permissions based on Table 18-7.<br />

Table 18-7. chmod Literal Number Values<br />

Value Description<br />

Basic Permissions<br />

400 Allows read by owner<br />

200 Allows write by owner<br />

100 Allows execute by owner<br />

040 Allows read by group<br />

020 Allows write by group<br />

010 Allows execute by group<br />

004 Allows read by everyone<br />

002 Allows write by everyone<br />

001 Allows execute by everyone<br />

Advanced Mode Selectors (Optional, and Generally Not Recommended<br />

to Use Unless You Really Know What You Are Doing)<br />

4000 Sets UID on execution bit (execution of file will run with permissions of file’s owner)<br />

2000 Sets GID on execution bit (execution of file will run with permissions of file’s group)<br />

1000 Sets sticky bit<br />

For example:<br />

chmod 755 filename<br />

would result in the filename having permissions -rwxr-xr-x.<br />

The other, symbolic way, of setting permissions is to use chmod in the following way:<br />

chmod [u][g][o]+/-[r][w][x] filename<br />

where u stands for owner, g stands for group, and o stands for other (everyone); followed by<br />

+ (for adding) or - (for denying) permissions (r, w, and x).<br />

For example, if you had a file with the permissions -rwxr-xr-x, but you wanted to allow anyone<br />

in its group to also write to the file, you could just use the following:<br />

chmod g+w filename<br />

CHAPTER 18 INTRODUCING DARWIN AND THE SHELL 321

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!