| Every file or directory has a set of
permissions that determines who can do what with it. Permissions are
represented by characters that control who may read, write, and
execute the contents of a file or directory.
The set of permissions for each
category of users (Users, Group or Other) consists of three possible
permission types. These are used to control access to the file or
directory with which the permissions are associated. The first
position in each set is the Read (r) permission, the second is Write
(w) and the third position is Execute (x). You may see a dash (-) in
place of r, w, or x. This indicates that the permission (r, w or x)
where the dash is located is denied.
Rolling over Figure
shows the permissions for the .profile file in the /home/user2
directory. This is a text file that is usually placed in the user's
home directory by the system administrator. When the user logs in,
this file is read, and the environment is tailored to the user's needs.
This file can be read (viewed) and written to (modified) by the user. The
set of permissions for User access to this file is r w -. The presence
of the r allows the User (Owner) to Read the file and the w allows the
User to Write to or modify the file. The absence of an x means the
User cannot Execute the file since this is not an executable file. A
dash is used in place of a permission that is not allowed. The group
and other categories of users can read the file but cannot write to it
or execute it.
Figure
also shows the permissions for the mkdir file in the /bin directory.
This is an executable UNIX command file which you have used previously
to create new directories. Since all users need to be able to use the
mkdir command, all three categories of users have the permission to
Read the file and to Execute it. The set of permissions for User,
Group and Other access to this file is r - x. The presence of the r
and x allows everyone (User, Group and Other) to Read and Execute the
file. The dash in place of the Write permission prevents anyone from
Writing to or changing the file.
The meaning of the r, w, and x
permissions will vary depending on whether you are working with a file
or a directory. Figure
shows the three possible permissions and the differences in their
effect on files and directories. In order for a directory to be of any
practical use, at least read and execute permissions must be
set.
Note - To copy (cp) a file from a
directory or move (mv) a file into or out of a directory, you must have
the execute (x) permission for the directory. You must also have the
read permission for the file being copied or moved.
Additionally, changing the permissions on a folder does NOT change the
permissions for that folder's subfolders. To change permissions
on a folder and all of its subfolders, the -R (recursive) command
needs to be used.
Figure
shows several examples of the different permissions for files and
directories.
|