Here's an example I found on Google:
-rw-r--r-- 1 wilker topology 337127 Aug 5 12:54 BOliver97.gif
Modification date: Aug 5 12:54
Permissions are like this:
Note the three sets of 'rwx'. They represent what someone is allowed to do with a file. The first three are for what you (or the owner, the one who made the file) can do with the file. The second is for people of the file's group. The third 'rwx' is for everybody else.
The group is something users can be a member of. Say there was a 'ourgroup' group. If you are in this group, the files you make will be in this group. Anyone else in this group can access the file according to how the second 'rwx' dictates.
rwx: R is for Read, W for Write, and X for eXecute. rwxrwxrwx means anyone is allowed to do anything with the file. If a place where a letter would be has a dash (r-- instead of rwx), these actions are not allowed on the file by that category of people (owner,group,world).
Let's look at the example:
The first dash is for something other than permissions. We see a 'rw-' after this. This is for the owner (wilker). He can Read and Write the file, but can't eXecute (can you execute a picture?).
Next we see 'r--'. This is for whoever is in the 'topology' group. W is blanked, so the file can't be modified. It is still readable.
The last three are also 'r--'. The rest of the world also only has read-only access.
Now for how to change these permissions with chmod. There are two ways to do it numbers (777) and letters (a+rwx).
Here's a way to remember the numbers:
['r'+'w'+'x'] ['r'+'w'+'x'] ['r'+'w'+'x']
[4+2+1] [4+2+1] [4+2+1]
7 7 7
["r"+"w"+"-"] ["r"+"-"+"-"] ["r"+"-"+"-"]
[4+2+0] [4+0+0] [4+0+0]
6 4 4
'chmod 644 [file]' gives 'rw-r--r--' permissions
The letters work like so:
chmod [a letter (u,g,o, or a)][+ or -][new permissions(like rwx)]
u means users (we are adding (not replacing) rw permissions to the first rwx)
g is for group (g+rw to add permissions to second rwx)
o is for the third rwx, everybody else
a is for everybody (rwxrwxrwx, not just three).
chmod 777 a_file
a_file now has rwxrwxrwx permissions
chmod 666 a_file
a_file now has rw-rw-rw- permissions
chmod 644 a_file
a_file now has rw-r--r-- permissions
The letter style adds permissions, while the number style replaces them. The end result with letter style is dependent on how the file was before.
See man page for more details:
BTW, Ricky, what is the fourth number for?
The first digit selects the set user ID (4) and set group ID (2) and save text image (1) attributes.
I saw this i the man page, but didn't get it .