zoukankan      html  css  js  c++  java
  • linux中ugo权限管理(chmod/chown)

    查看ugo权限: ll

     [root@localhost test]# ll

    total 12

    -rwxr-xr-x 2 root root 4 Oct  3 11:44 a

    lrwxrwxrwx 1 root root 1 Oct  3 15:57 a.soft -> a

    drwxr-xr-x 2 root root 6 Oct  3 15:54 b

    -rw-r--r-- 1 root root 3 Oct  3 11:09 cron

    -rwxr-xr-x 2 root root 4 Oct  3 11:44 p

    ugo分析说明:

    ugo:  user-group-other  除了x可执行权限,其他对root用户无约束力。

    针对-rw-r--r--的分析:第1位表示文件类型。2-10表示ugo权限,三位一段,一共三段。

    2-4位表示user文件属主权限。5-7位表示group文件属组权限。8-10位表示other权限。

    rwx权限对应的相关命令:

     对普通文件而言:

              r   --cat/tac/more/less/head/tail/vim

              w  ---vim :wq    >  >>   2>    2>>

              x    ---可执行。

    对目录文件而言:

             r         --ls

             w         --mkdir  touch  >  rm

             x          --- cd


    修改
    ugo权限:chmod

    [root@localhost test]# ll

    total 0

    -rw-r--r-- 1 root root 0 Oct  3 17:46 a

    -rw-r--r-- 1 root root 0 Oct  3 17:46 b

    -rw-r--r-- 1 root root 0 Oct  3 17:46 c

    [root@localhost test]# chmod +w a           --单独给userw权限,chmod u+w a  相同。

    [root@localhost test]# chmod a+w b          --ugo都加w权限。


    用8进制数字表示ugo权限:

    数字权限:三位一段,一共三段.(排列顺序必定是rwx,什么都不是,补位-,依次可用4 2 1 0表示)
    r    --read   4

    w  - write    2

    x   --execute  1

    -    --null  0

    [root@localhost test]# chmod 777 d.sh  ---给文件d.shugo都加rwx权限。

    修改文件属主与属组权限:chown  user:group file_name

     修改文件属主和属组:chown user:group file_name

    修改文件属主: chown user file_name

    修改文件属组:chown :group file_name

    修改文件属主及自动匹配属组: chown user:  file_name

    [root@localhost test]# ll e

    -rw-r--r-- 1 root root 0 Oct  3 17:50 e

    [root@localhost test]# id lbg

    uid=1000(lbg) gid=1000(lbg) groups=1000(lbg)

    [root@localhost test]# chown lbg e             --单独修改文件的属主

    [root@localhost test]# ll e

    -rw-r--r-- 1 lbg  root 0 Oct  3 17:50 e

    [root@localhost test]# chown :lbg f

    [root@localhost test]# ll f

    -rw-r--r-- 1 root lbg 0 Oct  3 17:50 f         ----单独修改文件的属组

    [root@localhost test]# chown lbg: g                    --修改文件属主和属组

    [root@localhost test]# ll g

    -rw-r--r-- 1 lbg lbg 0 Oct  3 18:00 g

    对目录权限修改时加上-R表示递归修改.(目录里面文件一起修改.)

    [root@localhost test]# chown -R lbg: ha

    [root@localhost ha]# ll /test/ha

    -rw-r--r-- 1 lbg lbg 0 Oct  3 18:01 1

    -rw-r--r-- 1 lbg lbg 0 Oct  3 18:01 3

  • 相关阅读:
    Python可视化库Matplotlib绘图基础学习
    字典特征和文本特征数据抽取
    ipc_11_快乐 happy
    关于Scanf的返回值问题
    [转]网站性能测试总结
    C语言运算符优先级
    成员运算符(·)和指向结构体成员运算符(->)的区别
    c++抛出异常与栈展开(stack unwinding)
    What is a Delegate?
    1.2 Variables and Arithmetic Expressions
  • 原文地址:https://www.cnblogs.com/lbg-database/p/10109976.html
Copyright © 2011-2022 走看看