Available as PDF
Remember when we first looked at the listing from
(Figure 12), and we skipped over
most of the symbols in the first column? Well, "They're
baaaack!" But that's OK, because we're ready for them now.
Let's take a closer look at a single entry from that listing, and see
if we can't demystify that first column.
-rw-r----- 1 picard STAFF 1397 May 28
OK, let's isolate the part in question: the first column. We'll diagram it so you understand what each position means.
After the first character, which identifies the entry type
d for a directory, and
a regular file.), you will find exactly nine (9) other characters. In
order to make sense of these, you have to break them up in your head, into
three groups of three symbols each (3 times 3 = 9).
The first three symbols represent the access permissions/attributes which apply to the user who owns the file (usually you).
The second group of three symbols represents the access permissions/attributes which apply to the group associated with the file. In UNIX, every userid is a member of one or more groups, and separate permissions/attributes can be set for the group, as opposed to the owner. In the example we used in Figure 12 (Chapter 22), the group associated with this file is "STAFF."
The third and last group of three symbols represents the access permissions and attributes which apply to all other userids (other than the owning user and members of the owning group).
Now, let's look at the individual sets of attributes. Each of the three sets (User, Group, and Others) is identical, with respect to the meaning of the three characters of which it is composed. That is to say, each of the three positions in each set means the same thing from set to set.
We'll just mention briefly the use of the
(change permission mode) command to change these attributes
and permissions, as this is getting into advanced territory, beyond the
scope of this introductory manual. However, it is important that you are
at least aware of these flags and their meanings so you can investigate
this area further when and if the need arises.
The basic form of the chmod command is:
who add-or-remove what_permissions filename
there should not be any spaces between the "who", "add-or-remove", and "what_permissions" portions of the command, in a real chmod command. The spaces were included in the above diagram to make it more readable. See the following examples for samples of proper syntax.)
We'll break that diagram down a little further, and then give some examples.
Command "Breakdown": chmod.
This is the name of the command.
u (for "user"),
(for "group"), or
a (for "all"--that
is, user, group, and others).
+ to add the attribute (set the flag), or
to remove the attribute (clear the flag).
r (for Read),
x (for Execute).
A file or directory name (or wildcard pattern) to which you wish to apply the listed permission changes.
Examples of Using chmod.
chmod a+r *
Makes all files in the current directory readable by anyone.
special.document so that you, the user/owner,
can't change it (without first issuing another chmod command to
make the file writable).
read permission so that everyone in the user's group can read