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.

322<br />

CHAPTER 18 INTRODUCING DARWIN AND THE SHELL<br />

This would effectively just add write permissions to the group for filename.<br />

Suppose you create a file and then wish to give special permissions to a group of people. By<br />

default, any file you create will have both the owner and group listed as you. You can change the<br />

group file to any other group that you belong to using the chgrp command with the following<br />

syntax:<br />

chgrp group filename<br />

To find out what groups you belong to you (and thus what’s available to you), you can use<br />

the id command, like so:<br />

<strong>Leopard</strong>:~ scott$ id<br />

uid=501(scott) gid=501(scott) groups=501(scott), 81(appserveradm),<br />

79(appserverusr), 80(admin)<br />

So in this case, if I wanted to allow anyone in the admin group to be able to write to my<br />

soliloquy4 file, I could do the following:<br />

<strong>Leopard</strong>:~/Documents/Shakespeare/macbeth scott$ chgrp admin soliloquy4<br />

<strong>Leopard</strong>:~/Documents/Shakespeare/macbeth scott$ ls -l<br />

total 8<br />

-rw-r--r--- 1 scott admin 409 May 17 10:44 soliloquy4<br />

<strong>Leopard</strong>:~/Documents/Shakespeare/macbeth scott$ chmod g+w soliloquy4<br />

<strong>Leopard</strong>:~/Documents/Shakespeare/macbeth scott$ ls -l<br />

total 8<br />

-rw-rw-r--- 1 scott admin 409 May 17 10:44 soliloquy4<br />

ACLs and Extended File Attributes<br />

ACLs (access control lists) and extended attributes were introduced to <strong>OS</strong> X in Tiger (<strong>OS</strong> X 10.4),<br />

but while they used to simply be an option available to those who wished to use them, in<br />

<strong>Leopard</strong> they are used by default.<br />

NOTE ACLs will only be available on your system locally if you are using the HFS+ file system.<br />

For network shares, they can be used over AFP and SMB/CIFS.<br />

ACLs allow fine-grained control of a file’s access far beyond UNIX’s traditional ownergroup-everyone<br />

permissions. With ACLs you can control specific permissions for specific users<br />

or groups, and you can treat each user and group differently.<br />

Specifically, each file on your system has one ACL, and each ACL may contain an ordered<br />

list of entries. Each entry sets specific permissions for a single user or group.<br />

NOTE If you have a user and a group with the same name, and you must differentiate these in<br />

an ACL, you may prefix the name with either user: or group: to specify which entity you are<br />

referring to.<br />

Files with entries in their ACL will include a + in the 11th character in the permission listing<br />

when you use ls -l. If there are no ACL entries, but there are other file attributes for the given<br />

file, then the 11th character will contain an @. If there are no ACL entries or attributes, then the<br />

11th character will contain a -.<br />

To view the ACL associated with a file, use the -e option with the ls command—for example,<br />

if I look in my home directory:

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

Saved successfully!

Ooh no, something went wrong!