• Linux chmod命令详解



        chmod命令用于改变linux系统文件或目录的访问权限。

    该命令有两种用法:

    一种是包含字母和操作符表达式的文字设定法;

    另一种是包含数字的数字设定法。

    文件或目录的访问权限分为只读,只写和可执行三种。

    chmod常见命令参数

    Usage: chmod [OPTION]... MODE[,MODE]... FILE...
      or:  chmod [OPTION]... OCTAL-MODE FILE...
      or:  chmod [OPTION]... --reference=RFILE FILE...
    Change the mode of each FILE to MODE.
    
      -c, --changes           like verbose but report only when a change is made
          --no-preserve-root  do not treat `/' specially (the default)
          --preserve-root     fail to operate recursively on `/'
      -f, --silent, --quiet   suppress most error messages
      -v, --verbose           output a diagnostic for every file processed
          --reference=RFILE   use RFILE's mode instead of MODE values
      -R, --recursive         change files and directories recursively
          --help     display this help and exit
          --version  output version information and exit
    

    常用的命令展示

    421 分别代表文件的读、写、执行的权限

    chmod:更改属性值的
    chmod 755 -R / 系统默认临界     【002:系统的默认掩码】
    chmod 644 /     系统默认临界     【cat /etc/profile|grep umask可以查看默认的umask值】

    增加文件所有用户组可执行权限

    chmod a+x log2012.log 【有的脚本无法执行就是没有x权限】

    同时修改不同用户权限,逗号分隔

    chmod ug+w,o-x log201.log

    使用“=”设置权限

    chmod u=x hhh.txt ==> chmod 100 hhh.txt

    为所有用户分配读权限

    chmod a=r file

    【更多参考】Linux 用户和用户组详解
  • 相关阅读:
    基于Python的人脸动漫转换
    let 与 var的区别
    【LeetCode】汇总
    【HDU】4632 Palindrome subsequence(回文子串的个数)
    【算法】均匀的生成圆内的随机点
    【LeetCode】725. Split Linked List in Parts
    【LeetCode】445. Add Two Numbers II
    【LeetCode】437. Path Sum III
    【LeetCode】222. Count Complete Tree Nodes
    【LeetCode】124. Binary Tree Maximum Path Sum
  • 原文地址:https://www.cnblogs.com/ftl1012/p/chmod.html
Copyright © 2020-2023  润新知