Q: How do I change permissions on my files?

A: UNIX file permissions are changed with the chmod command.

  1. Read/write permission is set up as an octal mask.

    In a long directory listing (ls -ll) there are 10 letters. The first is a d,l, or blank, and is usually not involved in the chmod operation. Then there are three sets of three r, w, and x.

    Example:

    rwxrwxrwx  1 login         2246 Nov 20 21:55 filename

    The r, w, and x mean read, write, execute respectively for the owner of the file (the first group of three), the UNIX group (the second group of three), and universally (the third group).

    Visualize it as:

    OOOGGGUUU

    where O=owner, G=group, U=universe

  2. The command, then, is arranged:

    chmod nnn filename

    where:
    the first "n" represents Owner permissions
    the second "n" represents Group permissions
    the third "n" represents Universal permissions
    and where "nnn" = any combination of numbers from 000 to 777.

    Example:

    chmod 740 test

    would look like this in an ls -ll

    rwxr   1 simpsotk geog           6 Jun 24 15:28 test*
  3. In the chmod command, each type of permission has a value associated with it.

    7 read, write, and execute permission
    6 read and write permission
    5 read and execute permission
    4 read permission
    3 write and execute permission
    2 write permission
    1 execute permission
    0 denial of permission

  4. Once you have used chmod, check the file using ls -ll to see the change made.
  5. To make changes without distinguishing whom is affected (i.e., you want everyone to have or not to have certain types of permissions), you can use the following types of commands:

    chmod r filename (to deny read permissions)
    chmod +r filename (to give read permissions)
    chmod w filename (to deny write permissions)
    chmod +w filename (to give write permissions)