Lesson 6: File Permissions

  1. Relevant Fields from the inode
    1. Owner of the file: uid
    2. Group Membership of the file: gid
    3. Permissions: read, write, execute
      	rwx	rwx	rwx
           owner group other
      1. the Read permission has a numeric value of 4
      2. the Write permission has a numeric value of 2
      3. the Execute permission has a numeric value of 1
      The total permissions assigned to a file for a particular identity is the sum of these three values.

  2. Relevant Commands
    1. chown Changes the ownership of a file. (Only superuser has this privilege)
    2. chgrp Changes the group of a file. (Only groups that you belong to)
    3. chmod Changes the permissions of a file.
      1. Numeric: chmod 640 letter # sets the permissions for a file
      2. Mnemonic: chmod ug+rw letter # changes the permission settings
    4. umask Sets the default mask applied to permissions for newly created files.

  3. Commands that require file permissions

    Permission

    File

    Directory

    Read (4)

    cat, more, file, head, tail, cp

    ls

    Write (2)

    vi, saving mail

    cp, mv, rm, ln

    Execute (1)

    $ command

    cd, ls -l, find


  4. Default permissions
    1. Default permissions for an ordinary file are: rw-rw-rw-     666
    2. Default permissions for directories are: rwxrwxrwx     777
    The umask is a three digit octal value whose bits strip away (mask off) default permissions: