国产宅男网站在线|亚洲A级性爱免费视频|亚洲中精品级在线|午夜福利AA毛

  • <dd id="gf5jf"><th id="gf5jf"></th></dd>

    <cite id="gf5jf"><label id="gf5jf"></label></cite>
  • <div id="gf5jf"><listing id="gf5jf"></listing></div>
    學(xué)習(xí)啦 > 學(xué)習(xí)電腦 > 操作系統(tǒng) > Linux教程 > Linux如何使用setfacl命令創(chuàng)建權(quán)限文件

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

    時(shí)間: 孫勝652 分享

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

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

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

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

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

      [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 // 此時(shí)user1才能對(duì)share有寫權(quán)限

      group::r-x

      mask::rwx

      other::r-x

      default:user::rwx //默認(rèn)子目錄或文件的權(quán)限信息

      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 進(jìn)入此目錄來檢測權(quán)限:

      [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 //查看新文件的權(quán)限

      # 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]$

      所以,當(dāng)有需求要做權(quán)根的繼承操作時(shí),可以使用這個(gè)方來實(shí)現(xiàn)。

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

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

    319240