Unix/Linux File Permission 101
If you are an aspiring unix/linux systems administrator, learning on how to set file permission is a must. This guide is not only for system administrators but for web developers as well. After reading this guide you will learn how to set the correct file permission with consideration on your system’s security.
There are 3 entities to consider in setting up file permissions.
- Owner - the one who created the file
- Group - the group which the owner of the file belongs to
- Others - refers to the rest of system users or groups
Lets take a look at this permission.
rwx-r-x-r-x
Looks familiar? Let me explain further. The first segment represent the owner permission, the second segment represent the group permission and the third represent the others.
Now that we know the 3 entities in setting up file permission, let us proceed to knowing what those almost cryptic letters (rwx-x-x) means. To start with, lets take a look at the letters and their equivalent numeric values.
r (ead) = 4
w (rite) = 2
x (ecute) = 1
Now that we know the r,w and x values. Lets have an example.
For example, we have a file named work.sql and we want the owner to have full access to the file, while giving the owner’s group and the others a read-only permission. Let us come up first with the letters representation of the permission we wanted to set.
Owner: rwx
Group: r--
Others: r--
By combining the letters above, the result is: rwx-r--r--
Now, how do we get the numerical values for the file permission that we wanted to set? Simple!, add the numerical values of each segment and you’ll get the permission in its numerical form. Lets do a little arithmetic here.
Owner: 7
Group: 4
Others: 4
The result will then be 744.
Now, lets proceed to setting up the permission.
To set the permission we will going to use the command chmod, which is available in unix/linux systems.
shell# chmod 744 work.sql

To check if you got the right file permission set.
shell# ls -ls work.sql
That’s all for now, next time i will going to discuss here the advanced setting up of file permissions. yes! you heard it right, we’re ain’t through yet. so cya!
Let me leave you with one file permission question to answer.
What is the numerical value of this file permission d- - - - - - - - - - -?
Post your answer as comment.
Spread the word
del.icio.us Digg Furl Google StumbleUpon Technorati Windows Live Yahoo! Help
Trackback uri
http://seoroot.com/blog/technology/security/unixlinux-file-permission-101.html/trackback



















3 Comments on Unix/Linux File Permission 101 »
Tabby @ 4:35 am:
wala man sa imong gidiscuss ang d——- pre???…
r (ead) = 4
w (rite) = 2
x (ecute) = 1
mao man kaya na ang legend??…sa roman numerical symbol d = 500..i think..hehehe…anyways, bery informative post.\m/^_^
Administrator @ 4:43 am:
LOL :D, you need to review the guide pre!
r = 4
w = 2
x = 1
rwx
you add up 4+2+1 = 7
if read-only access will be given then
r = 4
w = 0
x = 0
r–
you add them 4+0+0 = 4
if read-only and execute will be given then
r = 4
w = 0
x = 1
r-x
you add them 4+0+1 = 5
just an add-on tips
jim @ 2:30 pm:
d is for directory