Brief File & Folder Permission on *nix

File and folder permissions in *nix meaning slightly different, although the notation and writing it could same.

Folders
read (r) = user is allowed to see files that are inside, for example by typing ls to view the contents of the folder

write (w) = allowed users to create a new file in the folder, sometimes this also means that users who are allowed to modify, and delete files in the folder.

Execution (x) = user or allowed to move into the folder.

File
read (r) = allowed users to view / read the contents of the file

write (w) = allowed users to change and delete the file

execution (x) = when the executable file (the application or script) user is allowed to / run it.

Here is an example of the file permissions that are applied to a file or folder.

drwxr-xr-x 2 kids users – 512 Aug 26 2006 song /
-r – r – r – 1 kids users – 323 September 3 2003 README.txt
-rwxr-xr-x 1 kids users – 8 September 25 2003 super_pi

The file or folder permissions, as shown above consists of 3 pairs (triplet) rwx (rwx.rwx.rwx) 3, where the first point to the owner of a file or folder, 3, the second one for the group’s last 3 is for others.

The above example is seen to mark a folder as the folder permissions d in front of him. README.txt files and then only allowed to read only by all users when conditions such permissions, the owner and only root can modify and delete the file. super_pi temporary files is an application that has permissions to be in the execution.

Once you understand the meaning of read (r), write (w) and execution (x) let us continue to change the way the file permissions. There are several ways to change the file or folder permissions in * nix command but its always the same, namely chmod. But of course, only the owner of the files / folders that are allowed to change the permissions of the file / folder.

The first is to use the code form of letters, which as described above is in the file permissions symbolizes with the letters rwx example often used is as follows.

chmod a-x myfile.txt
chmod g rwx mydata /
chmod x test

a and g is applied to determine the permissions for whom. Meanwhile, the minus sign (-) means remove permissions from the files and folders is the plus sign (+) means to add these permissions files / folders concerned. The following is the full code.

u = user / owner / owner of a file or folder

g = group symbolizes the user group, which means that users who have access to one group as determined

o = other means users who are not owners of other files / folders and also not a group with a group given access.

a = All, all users.

In addition to the above code to facilitate the work if you must change the permissions of a folder and its contents are many, also have the option chmod-R, which means that the recursive or apply for the folder and its contents in his example by the use chmod recursive mode.

chmod -R o-rwx config

with command over the config folder and its contents will be set can not read, edit / delete and execution for the other (which is not the owner and one group).

How is using the next number. This one is way more popular than the above you just need to know the concept a little and it can change the permissions files or folders quickly and easily.

Like all things in life that the computer is always connected with the binary file permissions for starters taken from the binary. Because permissions are basically only 3 digits (triplet) character (rwx), so can imagine rwx = 111 binary. where 1 = active and 0 = not active. But that is usually easier to use but it is not a binary value decimal from the binary. It is this combination that may be used in the file permissions.

rwx = 111 = 2^2 + 2^1 + 2^ 0 = 4+2+1 = 7 (sign ^ = Square root)

r– = 100 = 4 + 0 + 0 = 4

rw- = 110 = 4 + 2 + 0 = 6

r-x = 101 = 4 + 0 + 1 = 5

An example of its defintely like the following.

chmod 777 = chmod a+rwx = rwxrwxrwx

and will be felt more easily when the need to give permissions for different users, and other groups such as the following.

chmod 750 readme.txt

The result as

-rwxr-x    to README.txt file

and if you want to change folder permissions with all the files and folders in the options give normal option -R as follows.

chmod -R 750 data/

To further please specify which own more easily assuming you do not until you can not executing a file permissions because it wrong.

Tags: , , , , , ,


Leave a Reply