• Linux文件属性


    文件属性和权限

    [root@daf root]# ls -al 
    total 64 
    drwxr-x---    4 root     root         4096 Feb 14 22:02 . 
    drwxr-xr-x   23 root     root         4096 Feb 16 13:35 .. 
    -rw-r--r--    1 root     root         1210 Feb 10 06:03 anaconda-ks.cfg 
    -rw-------    1 root     root        12447 Feb 14 23:22 .bash_history 
    -rw-r--r--    1 root     root           24 Jun 11  2000 .bash_logout 
    -rw-r--r--    1 root     root          234 Jul  6  2001 .bash_profile 
    -rw-r--r--    1 root     root          217 Feb  9 22:06 .bashrc 
    -rw-r--r--    1 root     root          210 Jun 11  2000 .cshrc 
    drwx------    2 root     root         4096 Feb 14 21:54 .gnupg 
    -rw-------    1 root     root            8 Feb 14 22:05 .mysql_history 
    drwx------    2 root     root         4096 Feb 10 00:44 .ssh 
    -rw-r--r--    1 root     root          196 Jul 11  2000 .tcshrc 
    -rw-r--r--    1 root     root         1126 Aug 24  1995 .Xresources

         一      二   三     四           五   六           七  
    [文件属性][节点数][作者][所属群组]   [大小][创建时间]   [文件名]

    *文件名中带有[ . ]开头的代表隐藏文件。
     
     
    文件类型代码:[ d ]--目录、[ - ]--文件、[ l ]--链接、[ b ]--可储存周边设备、[ c ]--序列设备。
     
    文件权限属性:[ r ]--可读、[ w ]--可写、[ x ]--可执行。
    *对于目录,必需具有执行权限才可进入
    *文件的执行属性将决定文件是否可执行,而与文件扩展名无关
     

    改变权限设置:

    chgrp :改变所属群组

    *要改变的群組名必须在 /etc/group 中存在
     
    语法: 
    chgrp 群组名 文件或目录

    如: 
    [root@test root]# chgrp users tmp 
    [root@test root]# ls –l 
    drwx------    2 root     root         4096 Oct 19 11:43 drakx/ 
    drwx------    2 root     users        4096 Oct 19 21:24 tmp/ 
    [root@test root]# chgrp testing tmp 
    chgrp: invalid group name `testing'   <==出错信息!


    chown :改变作者

     [ -R ] :同时对目录下的所有子目录或文件的作者进行修改
    *用户名必须已存在系统中,也就是在 /etc/passwd 中存在的用户名。 
    *chown 可直接修改所属群組
     
    语法: 
    chown [ -R ] 用户名 文件或目录 
    chown [ -R ] 用户名:群组名 文件或目录

    如: 
    [root@test root]# chown test tmp 
    [root@test root]# ls -l 
    total 28 
    drwx------    2 root     root         4096 Oct 19 11:43 drakx/ 
    drwx------    2 test     users        4096 Oct 19 21:24 tmp/ 
    [root@test root]# chown –R root:root tmp  
    [root@test root]# ls –l 
    drwx------    2 root     root         4096 Oct 19 11:43 drakx/ 
    drwx------    2 root     root         4096 Oct 19 21:24 tmp/

      
    chmod :改变权限属性

    方式一 数字类型改变
    三个基本属性:r、w、x的数字类型代表:r:4、w:2 、x:1

    语法: 
    chmod [-R] xyz 文件或目录 
    xyz 为三組 rwx 属性数值的相加

    同一组的数字是相加!如属性为 [ -rwxrwx--- ] ,则: 
    owner  = rwx  = 4+2+1 = 7 
    group  = rwx  = 4+2+1 = 7 
    others = ---  = 0+0+0 = 0

    [root@test root]# ls –al .bashrc 
    -rw-r--r--    1 root     root          226 Feb 16  2002 .bashrc 
    [root@test root]# chmod 777 .bashrc 
    [root@test root]# ls –al .bashrc

  • 相关阅读:
    实现路由的RouterMiddleware中间件
    AI: Jarvis
    使用管道(PipeLine)和批量(Batch)操作
    OSWatcher Black Box
    NET Core HTTP 管道
    开源项目!
    Router的创建者——RouteBuilder
    .NET Core)的ZooKeeper异步客户端
    single-write-database-connection
    Quartz与Spring集成 Job如何自动注入Spring容器托管的对象
  • 原文地址:https://www.cnblogs.com/bouygues/p/4479986.html
Copyright © 2020-2023  润新知