首页 > 编程知识 正文

lua创建文件,linux授权命令chmod

时间:2023-05-03 12:06:05 阅读:27232 作者:1388

setfacl是在Linux下设置文件访问控制列表的命令,允许您创建文件并继承目录权限。 一些功能类似于chmod命令。 以下小编介绍了Linux如何使用setfacl命令创建权限文件。 一起学习吧。

以下在root中使用一般用户user1。 目录/mnt下

在[ root @ red hat-7 mnt ] # setfacl-mu : user 1: rwx share//目录中添加ower=user1,并授予rwx权利路由。

[ root @ red hat-7 mnt ] #将默认acl权限添加到setfacl-d-mu : user 1: rwx share///目录中。 在此目录下创建的目录和文件将继承此权限信息

[root@redhat-7 mnt]#

[root@redhat-7 mnt]#

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

# file: share

# owner: root

#组: root

user:rwx

user:user1:rwx //此时,user1可以对share具有写入权限

组:r-x

掩码:rwx

other:r-x

default :用户:rwx//默认子目录或文件的权限信息

default : user : user 1: rwx

默认:组:r-x

默认:掩码:rwx

默认: other: r-x

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

[root@redhat-7 share]# ls

[ root @ red hat-7 share ] # touchroota

[ root @ red hat-7 share ] # touchrootb

[ root @ red hat-7 share ] # mkdir rootdir 1

[ root @ red hat-7 share ] # mkdir rootdir 2

[root@redhat-7 share]# ls

roota rootb rootdir1 rootdir2

[ root @ red hat-7 share ] # getfaclroota

# file: roota

# owner: root

#组: root

用户:rw -

用户:用户1: rwx # effective : rw -

组:r-x # effective : r--

掩码:rw -

other:r---

[ root @ red hat-7 share ] # getfaclrootdira

getfacl:rootdira:nosuchfileordirectory

[ root @ red hat-7 share ] # getfacl rootdir

rootdir1/rootdir2/

[ root @ red hat-7 share ] # getfacl rootdir 1

# file: rootdir1

# owner: root

#组: root

user:rwx

user:user1:rwx

组:r-x

掩码:rwx

other:r-x

default:user:rwx

default : user : user 1: rwx

默认:组:r-x

默认:掩码:rwx

默认: other: r-x

[root@redhat-7 share]#

在user1上访问此目录以检测权限。

[user1@redhat-7 share]$

[user1@redhat-7 share]$

[user1@redhat-7 share]$

[user1@redhat-7 share]$ ll

总体8

- rw-rw-r-- 1根根根0 nov 1922336052根

- rw-rw-r-- 1根根根0 nov 1922336052根

rwxrwxr-x2 root root6nov 1922336052 rootdir 1

rwxrwxr-x2根根根6 nov 1922:52根根2

[ user1@ red hat-7 share ] $ touchuser 1a

[ user1@ red hat-7 share ] $ touchuser 1dir 1

[ user1@ red hat-7 share ] $ getfacl user 1a///查看新文件的权限

# file :用户1a

# owner: user1

#组: user 1

用户:rw -

用户:用户1: rwx # effective : rw -

组:r-x # effective : r--

掩码:rw -

other:r---

[ user1@ red hat-7 share ] $ rmroota//root试图删除创建的文件。 成功了

[ user1@ red hat-7 share ] $ RM rootdir1//root成功尝试删除创建的目录

RM:cannotremovearootdir 1a:isa目录

[ user1@ red hat-7 share ] $ RM rootdir1- r

[user1@redhat-7 share]$ ll

总体4

- rw-rw-r-- 1根根根0 nov 1922336052根

rwxrwxr-x2根根根6 nov 1922:52根根2

- rw-rw-r-- 1用户1用户10 nov 1922336057用户1a

- rw-rw-r--1user1user 10 nov 1922336057 user 1dir 1

[user1@redhat-7 share]$

因此,需要进行权利根据的继承操作时,可以使用该方法来实现。

新的rhel7有一个类似setfacl的新工具chacl。

以上是Linux如何使用setfacl命令创建权限文件的介绍。 创建的文件继承了父目录的权限,在某些情况下很容易使用。 当然,setfacl命令还有其他用法。

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。