Under Linux and Mac OSX, sometime it is easier to change file permission with “chmod” command. Here are some basic on how to do this:
First, open up a terminal console and go to the file you would like to modify its permission structure. Example, a file under /home/vkick/ called test.txt
ls -l test.txt
and here is what it returns
-rw-r--r-- 1 vkick vkick 9649271 2011-07-05 15:02 test.txt
“-rw-r–r–” is the permission of this file. “vkick vkick” says the file owner is “vkick” and the group owner is “vkick”. For the file permission, here is how to read it…
From left to right, owner read/write/execute, group read/write/execute, world read/write/execute. In this example, it says owner has read and write permission and the group and the world only have read permission. One thing you want to remember is
read = 4
write = 2
execute = 1
If you want to give read & write permission, then it is read + write = 4 + 2 =6. And read/write/execute = 4 + 2 + 1 =7.
Get the idea?
Let’s say you want to give owner, group and the world all read and write permission, then you know it is going to be “666”. Easy, huh?
To change the permission, all you need to do is using the “chmod” command
chmod 666 test.txt
now run “ls -l” again and you can see the permission has been changed to the way you want it.
-rw-rw-rw- 1 vkick vkick 9649271 2011-07-05 15:02 test.txt