熱搜:win11繞過硬件限制安裝 一鍵重裝Win10系統(tǒng) 最干凈的u盤啟動(dòng)盤 真正純凈版的win7系統(tǒng)
時(shí)間:2015-01-21 13:35:02 作者:qipeng 來源:系統(tǒng)之家 1. 掃描二維碼隨時(shí)看資訊 2. 請(qǐng)使用手機(jī)瀏覽器訪問: https://m.xitongzhijia.net/xtjc/20150121/35445.html 手機(jī)查看 評(píng)論 反饋
setfacl是Linux下設(shè)置文件訪問控制列表的命令,可用來創(chuàng)建文件,能夠繼承目錄的權(quán)限,有些功能類似于chmod命令,下面小編就給大家介紹下Linux使用setfacl命令創(chuàng)建權(quán)限文件的方法,一起來學(xué)習(xí)下吧。
下面以 root 用普通用戶 user1 。在目錄/mnt下
。踨oot@RedHat-7 mnt]# setfacl -m u:user1:rwx share //為目錄添加ower = user1 ,并賦予rwx 的權(quán)根。
。踨oot@redhat-7 mnt]# setfacl -d -m u:user1:rwx share //為目錄添加默認(rèn)的acl權(quán)限,此目錄下創(chuàng)建目錄和文件都會(huì)繼承此權(quán)限信息
。踨oot@redhat-7 mnt]#
。踨oot@redhat-7 mnt]#
。踨oot@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
。踨oot@redhat-7 mnt]# cd share/
。踨oot@redhat-7 share]# ls
。踨oot@redhat-7 share]# touch roota
。踨oot@redhat-7 share]# touch rootb
[root@redhat-7 share]# mkdir rootdir1
。踨oot@redhat-7 share]# mkdir rootdir2
。踨oot@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--
。踨oot@redhat-7 share]# getfacl rootdira
getfacl: rootdira: No such file or directory
[root@redhat-7 share]# getfacl rootdir
rootdir1/ rootdir2/
。踨oot@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)入此目錄來檢測(cè)權(quán)限:
。踰ser1@redhat-7 share]$
。踰ser1@redhat-7 share]$
。踰ser1@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
。踰ser1@redhat-7 share]$ touch user1a
。踰ser1@redhat-7 share]$ touch user1dir1
。踰ser1@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
。踰ser1@redhat-7 share]$ rm rootdir1 -r
。踰ser1@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命令還有其他的用法。
發(fā)表評(píng)論
共0條
評(píng)論就這些咯,讓大家也知道你的獨(dú)特見解
立即評(píng)論以上留言僅代表用戶個(gè)人觀點(diǎn),不代表系統(tǒng)之家立場(chǎng)