What is chmod?
chmod means change mode, you need this file to tell the sytem how to read, write or execute files. Belive it or not ALL files have these set. There set either by the program, user or system.
* start *
Your chmod command allows you to chmod using 3 basic numbers, they are as follows. 4,2,1 ... later you will be adding these numbers to determine the proper chmod.
Your chmod also gives you 3 groups to chmod to Owner, Group and Public. Remeber this order it will NEVER change.
Owner = In the following examples root is the owner, in general who ever is the owner of the file
Group = If the file is in a group, the group permissions
Public = All users
The letters to indicate read, write and execute as we spoke about in the first paragraph are as follows "r" "w" "x", these will also NEVER change order.
Here is a layout:
Owner ---- Group ---- Public
4-2-1 ---- 4-2-1 ----- 4-2-1
r-w-x ---- r-w-x ------ r-w-x
Lets check a ls -la of some files we want to change:
-rw-r--r-- 1 root wheel 1790 Nov 30 00:15 test1
-rw-r--r-- 1 root wheel 818 Nov 30 00:15 test2
-rw-r--r-- 1 root wheel 1663 Nov 30 00:15 test3
Example 1 ( I want test1 to have Owner read, write and execute, group to have read and public to have read)
You would look under Owner tab, see the rwx, thats 421 add those it comes to 7. Now look under group read is a 4 (you dont need more more permissions so dont add them its only a 4). Now look under Public same thing its only a 4 dont add nothing).
The correct chmod would be # chmod 744 test1
Example 2 ( Change test2 to read, write, execute for all Owner, Group, Public)
Correct chmod would be # chmod 777 test2
Example 3 ( change test3 for Owner Write, Group Read and Public read )
Correct chmod would be # chmod 244 test3
Keep in mind ROOT can READ, WRITE and EXECUTE anything it wants too.
QUICK TIPS:
chmod +x sets a file "Execute"
chmod -x set a file "No Execute"
chmod +s sets a file "Set UID"
chmod -s sets a file "NO Set UID" (Some files NEED setuid BE CAREFULL with this one).
NOTE:
Please read the manual, these commands are REALLY basic you can get in depth with chmod after some reading.
Good Luck and be carefull.