精品丰满熟女一区二区三区_五月天亚洲欧美综合网_亚洲青青青在线观看_国产一区二区精选

  • <menu id="29e66"></menu>

    <bdo id="29e66"><mark id="29e66"><legend id="29e66"></legend></mark></bdo>

  • <pre id="29e66"><tt id="29e66"><rt id="29e66"></rt></tt></pre>

      <label id="29e66"></label><address id="29e66"><mark id="29e66"><strike id="29e66"></strike></mark></address>
      學習啦 > 學習電腦 > 操作系統(tǒng) > Linux教程 > Linux如何使用setfacl命令創(chuàng)建權限文件

      Linux如何使用setfacl命令創(chuàng)建權限文件

      時間: 孫勝652 分享

      Linux如何使用setfacl命令創(chuàng)建權限文件

        setfacl是Linux下設置文件訪問控制列表的命令,可用來創(chuàng)建文件,能夠繼承目錄的權限,有些功能類似于chmod命令,下面學習啦小編就給大家介紹下Linux使用setfacl命令創(chuàng)建權限文件的方法,一起來學習下吧。

        下面以 root 用普通用戶 user1 。在目錄/mnt下

        [root@RedHat-7 mnt]# setfacl -m u:user1:rwx share //為目錄添加ower = user1 ,并賦予rwx 的權根。

        [root@redhat-7 mnt]# setfacl -d -m u:user1:rwx share //為目錄添加默認的acl權限,此目錄下創(chuàng)建目錄和文件都會繼承此權限信息

        [root@redhat-7 mnt]#

        [root@redhat-7 mnt]#

        [root@redhat-7 mnt]# getfacl share //查看share的facl信息

        # file: share

        # owner: root

        # group: root

        user::rwx

        user:user1:rwx // 此時user1才能對share有寫權限

        group::r-x

        mask::rwx

        other::r-x

        default:user::rwx //默認子目錄或文件的權限信息

        default:user:user1:rwx

        default:group::r-x

        default:mask::rwx

        default:other::r-x

        [root@redhat-7 mnt]# cd share/

        [root@redhat-7 share]# ls

        [root@redhat-7 share]# touch roota

        [root@redhat-7 share]# touch rootb

        [root@redhat-7 share]# mkdir rootdir1

        [root@redhat-7 share]# mkdir rootdir2

        [root@redhat-7 share]# ls

        roota rootb rootdir1 rootdir2

        [root@redhat-7 share]# getfacl roota

        # file: roota

        # owner: root

        # group: root

        user::rw-

        user:user1:rwx #effective:rw-

        group::r-x #effective:r--

        mask::rw-

        other::r--

        [root@redhat-7 share]# getfacl rootdira

        getfacl: rootdira: No such file or directory

        [root@redhat-7 share]# getfacl rootdir

        rootdir1/ rootdir2/

        [root@redhat-7 share]# getfacl rootdir1

        # file: rootdir1

        # owner: root

        # group: root

        user::rwx

        user:user1:rwx

        group::r-x

        mask::rwx

        other::r-x

        default:user::rwx

        default:user:user1:rwx

        default:group::r-x

        default:mask::rwx

        default:other::r-x

        [root@redhat-7 share]#

        現(xiàn)在用user1 進入此目錄來檢測權限:

        [user1@redhat-7 share]$

        [user1@redhat-7 share]$

        [user1@redhat-7 share]$

        [user1@redhat-7 share]$ ll

        total 8

        -rw-rw-r--+ 1 root root 0 Nov 19 22:52 roota

        -rw-rw-r--+ 1 root root 0 Nov 19 22:52 rootb

        drwxrwxr-x+ 2 root root 6 Nov 19 22:52 rootdir1

        drwxrwxr-x+ 2 root root 6 Nov 19 22:52 rootdir2

        [user1@redhat-7 share]$ touch user1a

        [user1@redhat-7 share]$ touch user1dir1

        [user1@redhat-7 share]$ getfacl user1a //查看新文件的權限

        # file: user1a

        # owner: user1

        # group: user1

        user::rw-

        user:user1:rwx #effective:rw-

        group::r-x #effective:r--

        mask::rw-

        other::r--

        [user1@redhat-7 share]$ rm roota //嘗試刪除root創(chuàng)建的文件,成功

        [user1@redhat-7 share]$ rm rootdir1 //嘗試刪除root創(chuàng)建的目錄,成功

        rm: cannot remove arootdir1a: Is a directory

        [user1@redhat-7 share]$ rm rootdir1 -r

        [user1@redhat-7 share]$ ll

        total 4

        -rw-rw-r--+ 1 root root 0 Nov 19 22:52 rootb

        drwxrwxr-x+ 2 root root 6 Nov 19 22:52 rootdir2

        -rw-rw-r--+ 1 user1 user1 0 Nov 19 22:57 user1a

        -rw-rw-r--+ 1 user1 user1 0 Nov 19 22:57 user1dir1

        [user1@redhat-7 share]$

        所以,當有需求要做權根的繼承操作時,可以使用這個方來實現(xiàn)。

        在新的rhel7 中, 會有新的工具chacl 類似于 setfacl 。

        上面就是Linux使用setfacl命令創(chuàng)建權限文件的方法介紹了,因為創(chuàng)建的文件繼承了父目錄的權限,所以在某些時候使用比較方便,當然setfacl命令還有其他的用法。

      319240