1 如何禁止用户harry对/opt/private目录有任何权限,但不影响其他用户对此目录的访问
[root@server0 ~]# mkdir /opt/private
[root@server0 ~]# setfacl -m u:harry:- /opt/private/
[root@server0 ~]# getfacl /opt/private/
getfacl: Removing leading ‘/’ from absolute path names
file: opt/private/
owner: root
group: root
user::rwx
user:harry:— //确认结果
group::r-x
mask::r-x
other::r-x
2 新建目录/var/public,允许任何人写入,但禁止更改其他用户的文件
[root@server0 ~]# mkdir /var/public
[root@server0 ~]# chmod ugo=rwx /var/public
[root@server0 ~]# chmod o+t /var/public
[root@server0 ~]# ls -ld /var/public/
drwxrwxrwt. 2 root root 6 Nov 26 00:11 /var/public/
3 新建目录新建/tarena目录使用户gelin01对此目录具有rwx权限,其他人对此目录无任何权限
[root@svr7 ~]# mkdir /tarena
[root@svr7 ~]# useradd gelin01
[root@svr7 ~]# ls -ld /tarena/
drwxr-xr-x. 2 root root 6 3月 3 14:39 /tarena/
[root@svr7 ~]# chown gelin01 /tarena/
[root@svr7 ~]# chmod o=— /tarena/
[root@svr7 ~]# ls -ld /tarena/
drwxr-x—. 2 gelin01 root 6 3月 3 14:39 /tarena/
[root@svr7 ~]#
4 为lisi创建ACL访问权限,使得lisi可以查看/etc/shadow文件
[root@svr7 ~]# useradd lisi
[root@svr7 ~]# setfacl -m u:lisi:r /etc/shadow
[root@svr7 ~]# getfacl /etc/shadow
getfacl: Removing leading ‘/’ from absolute path names
file: etc/shadow
owner: root
group: root
user::—
user:lisi:r–
group::—
mask::r–
other::—
[root@svr7 ~]# su - lisi
[lisi@svr7 ~]$ cat /etc/shadow
root: 6