File Permissions in Linux

Associate
Joined
24 Oct 2008
Posts
582
Location
South London
I have just started to use Linux and after using windows for as long as I can remember am having trouble understanding file permissions. If someone were to give you this on paper can someone explain this for me please?

--w-r-x--x

I thought I understood the permissions till I saw the double -- that threw me off. I was thinking if it was -w-r-x would that mean no access to read write or to execute the file?

If someone could give me an explanation of the permission I wrote above would be greatly appreciated.
 
A quick brain dump:

There are 3 groups of permissions represented in the permissions string: --- --- ---

The first set is for the file owner, the second is for the group and the third is for everyone else.

There are 3 permissions for each set, r=read, w=write and x=execute = rwx and a permission is omitted by leaving it as a -.

e.g
rwx r-- --- : The owner can read/write/exec, group can read and no one else can do anything.

There are additional permissions you can do like sticky bits and permission strings are commonly represented as octal e.g 777 = rwxrwxrwx

Read here: http://www.linux.com/learn/tutorials/309527-understanding-linux-file-permissions and http://www.cyberciti.biz/faq/how-linux-file-permissions-work/
 
Thanks for that think I understand it a bit better now so for the one I wrote above. Would it be

File user can read/write/execute, group can exec no one else can do anything?
 
Nope.

So --w-r-x--x

Owner can write, group can read/exec and others can execute. The order is always the same, 9 letters of rwx rwx rwx, a hyphen in place of the letter indicates the permission not being set.

The extra initial hypen in --w-r-x--x is a type specifier, if it is just a '-' it means it's a standard file, and 'd' would indicate a directory.
 
Ok another question

the hyphen in between r and x now I can understand now that the hyphen after the write means now its moving to group permissions but why the hyphen in between the r and x? wouldn't it be easier to just do --w-rx--x?
 
The hyphens indicate that a permission isn't set. They aren't there as separators.

It’s _rwxrwxrwx

As stated above the first hyphen is the type specifier, not a permission.
 
Ok another question

the hyphen in between r and x now I can understand now that the hyphen after the write means now its moving to group permissions but why the hyphen in between the r and x? wouldn't it be easier to just do --w-rx--x?

Each permission appears in the same place for each object (user, group, other). Makes it easier to set and compare permissions on mass.

Sometimes you'll also see it written in a numerical form like:
chmod 777 file.txt

This will apply all permissions to all objects on the file. If you look at the binary for the number 7:
111

So each 1 is an on switch for R W X. Then you have three 7 (one for user,group and others).

Hope I've not over complicated things with a little extra info!
 
Back
Top Bottom