Search  
Resources & Services: Computing

Understanding Permissions

Mac OS X uses Unix style file permissions to control access to files. I you are having problems editing or viewing a file, it may be related to a file permission issue. You can also use permissions to protect your files from being altered by other users.


Who You Are

In the Unix world you are one on three people - owners, group members and everyone else. If you are the owner of a particular file/folder you have full control over that file/folder, but you can limit what other members of your group can do with this file. All users are also members of at least one group.

Reading Permissions

The first thing to understand permissions is to understand how to read permissions. From a command line typing ls -la would display a list of all the files in the current folder, with their permissions. Here is an example

 Permissions User Name User Group Date File/Dir Name
 drwxrwxr-x user course101 12 Oct 09:53 .
 drwxr-xr-x user course101 15 Sep 13:27 ..
 -rw-rw-r-- user course101 29 Aug 03:15 file1.txt
 drwxrwxr-x user course101 20 Sep 16:37 directory1
 -rwx------ user course101 11 Feb 2003 file2.txt
 drwxrwxrwx user course101 17 Jun 12:05 directory2

There are 4 groupings of characters that tell you information in the permissions.

Type
Owner
Group
Other
-
r
w
x
r
w
x
r
w
x

The first character identifies the entry. It will be set to one of the following settings:

d = Directory

l = Link

- = File

The next 3 sets of 3 characters correspond to the three types of users on the system (Owner, Group, Other). In each set there is a read (r), write (w), and a execute (x) setting.

r = Read, allows users to open and view a file/directory

w = Write, allows users to edit the file/directory

x = Execute, allows users to run an executable file

From the example above, you can see that file1.txt has its permissions set to:

-rw-rw-r--

This means the the owner (user) and group (course101) members can read and write to this file, Other users may only read the file.

Changing Permissions

When changing permissions on a file from a command prompt you will need to use the command chmod. The syntax for writing this command is this:

chmod -R 777 documents

This command would set the permissions on all the files/folders contained within the folder "documents" to full permissions for everyone (rwxrwxrwx).

The -R flag makes the command recursive

The 777 tells the command what permissions to apply to each group (7 for Owner, 7 for Group and 7 for Others). Here is how we came up with these values

  Permission
Letter Representation
Number Value
  Read
r
4
  Write
w
2
  Execute
x
1
  None
-
0

These values can be combined to create any combination of permissions, as shown here.

Permission Setting
Calculated
Letter
Representation
Translation
0
0
---
No Permissions
1
1
--x
Execute Only
2
2
-w-
Write Only
3
2+1
-wx
Write/Execute Only
4
4
r--
Read Only
5
4+1
r-x
Read/Execute Only
6
4+2
rw-
Read/Write Only
7
4+2+1
rwx
Read/Write/Execute

Samples

       
Everyone can do anything - very insecure
       
Permissions Seen
rwx
rwx
rwx
Permission Value
(4+2+1)
(4+2+1)
(4+2+1)
Permission Setting
7
7
7
       
Read/Write for owner and group, everyone else can only read - moderately secure
 
rw-
rw-
r--
 
(4+2+0)
(4+2+0)
(4+0+0)
 
6
6
4
       
Full Control for owner and read only for group -very secure
 
rwx
r--
---
 
(4+2+1)
(4+0+0)
(0+0+0)
 
7
4
0
       

You can view a more detailed article regarding permissions at OSX faq.

Search