File & Directory Permissions & OwnershipIf you've ever used file sharing on your Mac, you probably noticed that you can set permissions for folders and files, giving certain users, groups of users, or everyone read-only, read-write, or no access. (This is covered in Chapter 4.) Unix has almost the same system with users, groups, and public permissions. Through the ls command, which I cover earlier in this chapter, you can learn quite a bit more about the ownership and permissions of files on your system. For example, take a look at the ls -la listing for a home directory, in Figure 57. There's lots of useful information on each line. Figure 57. A directory listing including permissions and other information for files.The first line (starting with the word total) is the number of 512-byte blocks used by the files in the directories that follow. Below that, each line contains seven columns of information about each subdirectory and file. PermissionsThe group of characters at the beginning of the line (for example, drwxr-xr-x in the first entry) indicates the entry's type and permissions. The first character indicates the type of entry:
The next nine characters of the permissions can be broken into three sets of three characters each. The first set of three is permissions for the owner of the file, the second set is permissions for the group owner, and the third set is permissions for everyone else who has access to the entry.
For example, the file named example.rtf in Figure 57 can be written to and read by the owner (ronh) and can only be read by the group (staff) and everyone else. LinksThe next column shows the number of links. This is a count of the files and directories contained within a directory entry. It's set to 1 for normal files. OwnerThe third column is the owner of the file or directory. Normally this will be the name of your account. Sometimes, the system creates files for you, and you may see another owner. For example, the .. directory in Figure 57 was created by the system, which gave ownership to root, the superuser. GroupThe group is listed next. Just as in file sharing in Mac OS 9.x and earlier, you can create groups of users that have separate permissions. To find out what group you are a member of, type groups and press . When your account is created, a group is also created with the same name as your short name, with you as the sole member of the group. If you want special groups for people (for example, marketing, staff, sysadmins), you can set these up using NetInfo Manager if you are an administrator of the system. File sizeThe number in the fifth column gives the size of the entry in bytes. Modification dateThe sixth column shows the date and time that the file or directory was last modified. A directory is modified whenever any of its contents are modified. FilenameLast, you see the name of the file or directory. |