CMMG Biocomputing Facility
Online Help Guides

Setting File Permissions in UNIX

[ Genetics Computer | GCG | Windows 95 | Online Guides | CMMG Home ]



FILE PERMISSIONS IN UNIX

Files and directories in the UNIX File System have a set of "permissions"
that determines who is allowed access to them.  The permissions are "read"
(the ability to read or copy the file or directory), "write" (the ability
to edit, delete, or otherwise change the file or directory), and "execute"
(the ability to execute a program file or to change into and browse a
directory).  The level of each of those permissions is assigned to each of
3 different types of people: the owner of the file (e.g. you own the files
in your home directory), members of the owner's group (a group can be
comprised of any set of users), and the world (everyone else with an
account on the computer, not really the whole world).

If you wish to change the permissions on your files or directories, for
example so that others cannot read them, use the chmod (change mode)
command: 

chmod XXX filename

where XXX is the 3-digit permissions code (see below) and filename is the
name of the file (or directory) you wish to change.

To make a FILE readable only by you: chmod 600 filename

To make a DIRECTORY readable only by you: chmod 700 dirname

DO NOT do that to your home directory.  If you wish to use a secure
directory, create a new subdirectory below your home directory (mkdir
newdirname), and then make it secure by typing chmod 700 newdirname

EXPLANATION:  There is a 3-digit code entered after "chmod" and before
"filename".  The first digit represents the permissions for the owner, the
second is for the group, and the third is for other users.  4 is read, 2
is write, and 1 is execute, and the codes are additive.  Therefore 4+2=6
(read & write), 4+1=5 (read & execute), and 4+2+1=7 (read, write, &
execute) and so forth.  By default, newly created files are set to 644
(read and write for the owner, read for everyone else), and new
directories are set to 755 (read, write, and execute for the owner, read
and execute for others). 

To list the current permissions of a file:

ls -l filename

-rw-r--r--   1 username      2860 Jul 30 15:48 filename

In that example, the owner has read (r) and write (w) permissions, and the
group and others have only read permissions (i.e. 644).  Other info listed
includes the username of the file's owner, the size of the file, the date
and time the file was last modified, and the name of the file. 

To restore default permissions on a FILE: chmod 644 filename

To restore default permissions on a DIRECTORY: chmod 755 dirname

You may use the chmod command only on files that you own.


[ Genetics Computer | GCG | Windows 95 | Online Guides | CMMG Home ]


Send comments to: dwomble@genetics.wayne.edu

Copyright © 2001, David D. Womble.