2015年8月31日 星期一

Chapter 6. Controlling Access to Files with Linux File System Permissions.

  1. Linux file system permissions

    Access to files by users are controlled by file permissions.

    r (read)    = 4
    w (write)  = 2
    x (exec)   = 1
     
  2. Viewing file/directory per missions and ownership

    # ls -l
     

     
  3. Changing file/directory permissions
    # chmod whowhatwhich file|directory
    who is u, g, o, a (for user, group, other, all)what is +, -, = (for add, remove, set exactly)which is r, w, x (for read, write, executable)# chmod ### file|directory
    # is sum of r = 4, w = 2, and x = 1
     
  4. Changing file/directory user or group ownership

    # chown owner:group file|directory
    chown can be used with the -R option to recursively change the
    ownership of an entire directory tree.
     
  5. Special  permissions


     
  6. Default file permissions

    # umask
    0002 

    後面三個數字與一般權限有關,
    第一個數字表示特殊權限(參考上面第5點說明)。
         0          0           0           2
    special + user + group + other
    此 umask 表示:使用者新增檔案或目錄時,針對 other 的
    權限要扣除 2,也就是不開放寫入權限。

    ※ 關於預設 umask 的設定可以參考 /etc/bashrc 這個檔案的內容