This string:
-rwxr-xr-x
Is separated into four sections:
- indicates what kind of file it is rwx (first 3) owner permissions r-x (second 3) group permissions r-x (last 3) other permissions
All together, this string is supposed to provide (at a glance) the most important aspects of a file. Namely what it is and who can do what with it.
First Section
The first character in the string is reserved for the file type. Any regular old file will simply have a - in this position. Other include:
d directory p pipe/fifo l link c character device file b block device file s local domain socket
So a pipe might look like this:
prwx------ root root filename
Second - Third - Fourth Section
The next 9 bits describe the permissions that everyone has when it comes to this file. There are three types of permissions:
r read (opening the file for reading, can't save changes) w write (change the contents of file) x execute (run the file, like a script or binary)
And there are three groups to which these permissions may be applied to:
owner whoever owns the file (as seen by the output of ls -l) group whoever is part of the group owner of this file others anyone who doesn't fall in either of the two above categories
For example:
-rwxr-xr-x 1 pavan employee 672 DEC 20 2000 pavan.sh pavan is the owner employee is the group owner name anyone else falls into "others"
Referring to the above example, if we want to make pavan have full control over the file, let anyone in the employee group to read or execute the file and block all permissions to others:
-rwxr-x---
The numbers
The reason permissions are sometimes represented with numbers is that it is generally easier to use an octal representation of the 9 bits (I still prefer straight up rwx).
To understand what the numbers mean you need to build a table (if you've ever done work with binary this will help):
# r w x 0 0 0 0 1 0 0 1 2 0 1 0 3 0 1 1 4 1 0 0 5 1 0 1 6 1 1 0 7 1 1 1
You refer to this chart for each set of three bits. For example, if I decide to give the owner of the file complete control (r,w and x), only read for the group and also only read for others:
rwx owner corresponds to 7 in the table r-- group corresponds to 4 in the table r-- other corresponds to 4 in the table Therefore my file has permissions 744
man 1 ls