Linux and Mac OS X both use a POSIX-compatible type of filesystem. This has to do with the way files are accessed by their owner and others. Files and folders have permissions for 3 different types of users:
- Owner: this is the user who owns the file or folder
- Group: this is the permissions for any user in the group that the file belongs to
- Others: this is the permissions for all other users who don't fall into one of the two above categories
For each of these types of users, there are 3 different permissions which can be either granted or not granted, they are:
- read (4) - gives that type of user the ability to read the file
- write (2) - gives that type of user the ability to write to the file
- execute (1) - gives that type of user the ability to execute the file as a program
Each of these types of permissions has an octal number associated with it (the number in parenthesis after it). To assign a file or folder more than one permission, add these numbers together. For example, to make a file both readable and writeable it would have the value 6 (4 + 2 = 6). Here's a list of all of the possible combinations:
The owner, group, and others each a digit to define permission for that type of user. For example a file or folder which has read, write, and execute permission by the owner, read and write permission by the group, and read permission by others would have to be 764 (rwxrw-r--). Similarly a file which is readable and writeable by the owner and group only would be 660 (rw-rw----). To view a file or folder's current permissions, use the ls command with the -l flag:
$ ls -l -rw-r--r-- 1 user group 6644 2010-07-09 21:49 grep.py drwxr-xr-x 3 user group 4096 2010-04-16 00:49 handbrake -rw-r--r-- 1 user group 2773 2010-05-28 02:19 info.txt -rw-r--r-- 1 user group 4542 2010-04-28 16:14 picture.png
To change the permissions of a file, use the chmod command followed by the octal permissions followed by the filename. For more information, see this article on common commands. Here is a brief example:
user@computer:~ $ ls -l winetricks -rw-r--r-- 1 user group 161664 2010-05-26 19:44 winetricks user@computer:~ $ chmod 775 winetricks user@computer:~ $ ls -l winetricks -rwxrwxr-x 1 user group 161664 2010-05-26 19:44 winetricks
To recursively change the permissions on a set of files and folders, use the -R flag: chmod -R 775 thedirectory/ .





