• umask的含义


    when a file is newly created, what's this file's default permission?

         depend on the environment variable "umask"

           what does it mean?

           where is it located? (check the file: /etc/profile)

      check your umask, run

        $ umask

        on my system, this will print: 022

        what does it mean? what's the default perm?

        why choose umask this value?

      what's the least permissive (most secure) value for umask?

        how to set that value to your umask?

    ---------------------------------------------------------

    umask=022中"022"是八进制的写法,如果换成二进制是000010010
    在unix中文件权限是三类用户,三种权限。三类用户分别是文件所有者user(u),文件所有者所在主群组group(g)、其它用户others(o),三种权限分别是起读read(r)、写write(w)、执行execute(x)。
    如果一个文件的权限如下:所有者有读写的权限,群组有读和执行权限、其它用户有读权限,可以写成:
    rw-r-xr--
    其中前三位指明了所有者的权限、中间三位指明了组权限、最后三位指明了其它用户的权限。我们用ls -l可以看到文件权限详情,列出来的是10位,最前一位如果是d表示是子目录。
    说回来,如果把这上面9位字母换成二进制数则是:
    110101100
    如果换成八进制是多少?
    因此文件权限可以用9位二进制数表示。umask在英文中是屏蔽的意思,那么
    umask=022
    指屏蔽文件的022权限,到底屏蔽了什么?将这个八进制数用二进制表示
    000010010
    换算成字母是
    ----w--w-
    指取消组的写权限、取消其它用户的写权限。
    屏蔽这些权限后,剩下什么权限呢?用字母表示是:
    rwxr-xr-x
    用二进制数表示是:
    111101101
    你可以对比一下
    000010010
    可以知道屏蔽前后的换算关系。

  • 相关阅读:
    spring filter and interceptor
    spring 与 swagger 2 的整合
    spring 异步操作
    图片延迟加载 jquery,lazyload.js 调用的demo
    一、Spring的第一个课时
    线程的基本了解
    HTTPS/HTTP监听常见问题
    Leetcode 118 杨辉三角
    HashSet的源码解释
    HashMap源码理解
  • 原文地址:https://www.cnblogs.com/xingyun/p/2274477.html
Copyright © 2020-2023  润新知