More on File Permissions


What you can and can't do with a file, as defined by your username or group name, is pretty much wrapped up in four little letters. Look at the following listing (using ls -l) for an example. The permissions are at the beginning of each line.

 -rw-r--r--  1 mgagne mgagne      937 May 17 13:22 conf_details -rwxr-xr-x  1 root   root   45916220 Apr  4 12:25 gimp -rw-r--r--  1 root   root        826 Feb 12 09:43 mail_test -rw-r--r--  1 mgagne mgagne    44595 May 17 13:22 sk_open.jpg 

Each of these letters in turn can be referenced by a number. They are r, w, x, and s. Their numerical representations are 4, 2, 1, and "it depends." To understand all that, you need to do a little binary math.

Reading from right to left, think of the x as being in position 0. The w, then, is in position 1 and the r is in position 2. Here's the way it works:

2 to the power of 0 equals 1

(x is 1)

2 to the power of 1 equals 2

(w is 2)

2 to the power of 2 equals 4

(r is 4)


In order to specify multiple permissions, you can just add the numbers together. If you want to specify both read and execute permissions, simply add 4 and 1 and you get 5. For all permissions (rwx), use 7.

File permissions are referenced in groups of three rwx sections. The r stands for "read," the w means "write," and the x denotes that the file is executable.

While these permissions are arranged in three groups of three rwx combinations, their meaning is the same in all cases. The difference has to do with who they represent rather than the permissions themselves. The first of these three represents the user, the second trio stands for the group permissions, and the third represents everybody that doesn't fit into either of the first two categories.

The commands you will use for changing these basic permissions are chmod, chown, and chgrp.

chmod

CHange the MODe of a file (aka its permissions).

chown

CHange the OWNer of the file or directory.

chgrp

CHange the GRouP of the file or directory.




Moving to Linux(c) Kiss the Blue Screen of Death Goodbye!
Moving to Linux: Kiss the Blue Screen of Death Goodbye!
ISBN: 0321159985
EAN: 2147483647
Year: 2003
Pages: 247

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net