Up to main menu
Back to Shell Scripts
Next: Internet Facilities
Read/Write/Execute Permissions
To see who has permission to read/write/execute a given
file (or directory), use ls -l;
pascal> ls -l myprogram.f90
-rw-r--r-- 1 smith math6000 1152 Sep 5 10:32 myprogram.f90
The 10 characters at the far left of this ``long'' listing
indicate the permissions for the file;
in this case, "smith" (the owner of the file) has
read & write permission but everybody else only
has read permission.
(See ``How to Change Permissions''.)
The interpretation of those 10 characters:
- the first character is - for a ``normal''
file, d for a directory
- the next three characters are rwx
according to whether the owner of the file
has read, write, and/or executable permission
for that file. (``Executable'' is meaningless unless
the file is a shell script, compiled program, or directory.
In the case of a directory, ``executable'' means
that one is allowed to cd to that directory.)
- the next three characters (characters #5-#7) refer
to the group permissions on that file.
In the example above, the group that smith
belongs to is ``math6000''.
- the final three characters (characters #8-#10) refer
to the permissions for everybody else who has a login
on the computer -- so-called ``world permissions''.
Rarely do you want the world to have write permission
on your files, or even execution permission, but it
is common to make files world-readable in which case
those three characters will be r--
Examples
pascal> ls -l file1
-rw------- 2 smith math6000 3287 Apr 8 12:10 file1
The owner of the file has read and write permission.
pascal> ls -l file2
-rw-r--r-- 2 smith math6000 3287 Apr 8 12:11 file2
The owner has read and write permission. Everyone
else - the group and all other users - can read the
file.
pascal> ls -l myprog
-rwx--x--x 2 smith math6000 3287 Apr 8 12:10 myprog
The user has read, write and execute permission.
Everyone else -the group and all others- can execute
the file.
pascal> ls -l
drwxr-x--- 2 smith math6000 1024 Jun 17 10:00 SCCS
This is a directory. The user has read, write and
execute permission. The math6000 group has
read and execute permission on the directory.
Nobody else can get access to it.
Use the Unix command chmod
to change the permissions on a file or directory
that you own. (It won't work on somebody else's file!)
The manual page for chmod gives several variations
of usage, but the most direct method is to give a 3-digit
code with the command to set permissions for yourself,
your group, and the world.
Each of the 3 digits reflects the sum of
the three kinds of permissions;
read=4, write=2, execute=1.
- chmod 600 filename = you have read/write permission,
everybody else has *no* permission
- chmod 644 filename = you have read/write permission,
everybody else has only read-permission
- chmod 754 filename = you have read/write/execute permissions,
your group has only read and execute permission,
and everybody else has only read permission
- chmod 755 directoryname = you have read/write/execute
permission on the directory, which means that you can reside in
the directory (x), list its contents (r), and add/delete/rename files
in the directory (w).
Everybody else can only reside in (cd to) and
list the contents of (ls) the directory,
but not alter its contents.
Up to main menu
Back to Shell Scripts
Next: Internet Facilities
Bruce.Fast@Colorado.EDU