博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
linux特殊权限管理,linux文件访问特殊权限的设置
阅读量:6903 次
发布时间:2019-06-27

本文共 4796 字,大约阅读时间需要 15 分钟。

文件访问特殊权限的设置

1 对文件或者目录都可以设置ACL

现在有个目录money,权限如下:

94475416_1

(1)针对某用户的特殊权限的添加,修改,删除

*如果我想这个目录对kiosk这一个用户有特殊权限,比如有读取,执行权限

[kiosk@foundation21 Desktop]$ su -

Password:

Last login: 日11月2 09:15:43 CST 2014 on pts/1

Last failed login: 日11月2 09:37:02 CST 2014 on pts/1

There was 1 failed login attempt since the last successful login.

[root@foundation21 ~]# setfacl -m u:kiosk:rx /mnt/money/

[root@foundation21 ~]# ll /mnt/money/

total 0

[root@foundation21 ~]# ll -d /mnt/money/

drwxr-x---+ 2 root root 6 Nov  2 09:23 /mnt/money/

[root@foundation21 ~]# logout

[kiosk@foundation21 Desktop]$ cd /mnt/money/

[kiosk@foundation21 money]$ ls

[kiosk@foundation21 money]$

*查看这个文件的详细权限列表

[root@foundation21 ~]# ll -d /mnt/money/

drwxr-x---+ 2 root root 6 Nov  2 09:23 /mnt/money/

《注意:原来的 .变成+了,此时用ll看到的权限不一定准确,要用getfacl》

[root@foundation21 ~]# getfacl /mnt/money/

getfacl: Removing leading '/' from absolute path names

# file: mnt/money/

# owner: root

# group: root

user::rwx

user:kiosk:r-x

group::r-x

mask::r-x

other::---

各行的意义如下:

94475416_2

* 如果我想把这个用户的特殊权限删掉

[root@foundation21 ~]# setfacl -x u:kiosk /mnt/money/

[root@foundation21 ~]# getfacl /mnt/money/

getfacl: Removing leading '/' from absolute path names

# file: mnt/money/

# owner: root

# group: root

user::rwx

group::r-x

mask::r-x

other::---

《但是ll时文件的权限上还是有+。因为权限列表为空,但是权限列表还在》

[root@foundation21 ~]# ll -d /mnt/money/

drwxr-x---+ 2 root root 6 Nov  2 09:23 /mnt/money/

[root@foundation21 ~]# setfacl -b /mnt/money/  这样就把和文件相连的权限列表删除

[root@foundation21 ~]# ll -d /mnt/money/

drwxr-x---. 2 root root 6 Nov  2 09:23 /mnt/money/

[root@foundation21 ~]#

(2)针对某组的特殊权限的添加,修改,删除

同(1)把u改为g就行了

(3)针对其他人的特殊权限的添加,删除,修改

[root@foundation21 ~]# setfacl -m o:kiosk:rx /mnt/money/

setfacl: Option -m: Invalid argument near character 3

[root@foundation21 ~]#

《o不能指定 特定用户或者组,因为它本生就是除了某些组,某些用户之外的其他所有人》

[root@foundation21 ~]# setfacl -m o::rw /mnt/money/

[root@foundation21 ~]# getfacl /mnt/money

getfacl: Removing leading '/' from absolute path names

# file: mnt/money

# owner: root

# group: root

user::rwx

group::r-x

other::rw-

2 mask的更改以及作用

表示该文件可以指派出去的最大的权限

(1)给组kiosk的权限rwx

[root@foundation21 ~]# setfacl -m g:kiosk:rwx /mnt/money/

[root@foundation21 ~]# getfacl /mnt/money/

getfacl: Removing leading '/' from absolute path names

# file: mnt/money/

# owner: root

# group: root

user::rwx

group::r-x

group:kiosk:rwx

mask::rwx

other::rw-

在redhat6以及之前的版本中,用户建立的分区时不支持acl的,如果需要,必须加载acl参数:

mount -o remount,acl 设备

vim /etc/fstab

设备 挂载点 类型 defaults,acl 0 0

(2)修改mask

[root@foundation21 ~]# setfacl -m m:rw /mnt/money/

(3)指派出去的有效权限随着mask而改变

[root@foundation21 ~]# getfacl /mnt/money/

getfacl: Removing leading '/' from absolute path names

# file: mnt/money/

# owner: root

# group: root

user::rwx

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

group:kiosk:rwx #effective:rw-

mask::rw-

other::rw-

[root@foundation21 ~]#

(4)mask并不影响other的有效权限

[root@foundation21 ~]# setfacl -m m:r /mnt/money/

[root@foundation21 ~]# getfacl /mnt/money/

getfacl: Removing leading '/' from absolute path names

# file: mnt/money/

# owner: root

# group: root

user::rwx

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

group:kiosk:rwx #effective:r--

mask::r--

other::rw-

(5)chmod也会改变改变文件的mask,要慎重

本来mask是rw

[root@foundation21 ~]# chmod 444 /mnt/money/

[root@foundation21 ~]# getfacl /mnt/money/

getfacl: Removing leading '/' from absolute path names

# file: mnt/money/

# owner: root

# group: root

user::r--

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

group:kiosk:rwx #effective:r--

mask::r--

other::r--

3 目录里的文件的acl

(1)目录里新建文件时,文件默认没有ACL。

[root@foundation21 ~]# getfacl /mnt/money

getfacl: Removing leading '/' from absolute path names

# file: mnt/money

# owner: root

# group: root

user::r--

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

group:kiosk:rwx #effective:rw-

mask::rw-

other::r--

[root@foundation21 ~]# touch /mnt/money/file

[root@foundation21 ~]# ls /mnt/money/file

/mnt/money/file

[root@foundation21 ~]# ll /mnt/money/file

-rw-r--r--. 1 root root 0 Nov  2 10:13 /mnt/money/file

(2)指定目录当中内容的ACL(不包含目录本身)

[root@foundation21 ~]# setfacl -m d:u:kiosk:r /mnt/money/

[root@foundation21 ~]# touch /mnt/money/d_file

[root@foundation21 ~]# getfacl /mnt/money/d_file

getfacl: Removing leading '/' from absolute path names

# file: mnt/money/d_file

# owner: root

# group: root

user::r--

user:kiosk:r--

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

mask::r--

other::r--

《setfacl -m d:u:kiosk:r /mnt/money/ 指定了目录下的内容的ACL权限。而目录本身的ACL权限保持原有的不变,该目录下的内容与目录的ACL权限也没有关系!》

[root@foundation21 ~]# getfacl /mnt/money

getfacl: Removing leading '/' from absolute path names

# file: mnt/money

# owner: root

# group: root

user::r--

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

group:kiosk:rwx#effective:rw-

mask::rw-

other::r--《这部分是目录的ACL》

default:user::r--

default:user:kiosk:r--

default:group::r-x

default:mask::r-x

default:other::r--《这部分是目录内文件的ACL》

4 对没有开启ACL的文件系统的处理

sda3是我新划分出来的分区,并格式成立ext4格式。可以看到在ext4文件系统上设置ACL时是不支持的。用tune2fs命令,来开启磁盘的ACL功能。

94475416_3

查看以下磁盘是否开启了ACL功能:

94475416_4

转载地址:http://sqodl.baihongyu.com/

你可能感兴趣的文章
关于使用chrome插件改动全部的站点的响应responseHeaders头的注意
查看>>
hibernate下载包中配置文件路径
查看>>
项目命名规则
查看>>
C语言 · 字符串输入输出函数
查看>>
css中单位em和rem
查看>>
C#编程(二十一)----------扩展方法
查看>>
BZOJ 2141: 排队 [CDQ分治]
查看>>
netty5入门教程
查看>>
SecureCRT 连接虚拟机Linux
查看>>
你是否也忘了刷新视图?
查看>>
C语言 · 数的划分
查看>>
C# 超高速高性能写日志 代码开源
查看>>
js-jquery-SweetAlert【二】配置方法
查看>>
反向传播公式
查看>>
轻松学习Ionic (二) 为Android项目集成Crosswalk(更新官方命令行工具)
查看>>
c 变量的存储类型auto等(基础知识)和c函数变量
查看>>
树莓派的GPIO编程
查看>>
sql server 2008如何导入mdf,ldf文件
查看>>
让Asp.Net WebAPI支持OData查询,排序,过滤。(转)
查看>>
在centos中安装mangodb
查看>>