DAY05 作业

1、新建目录要求如下:

1)/pub目录为公共存储目录对所有用户可以读,写,执行,但用户只能删除属于自己的文件(t权限)

2)/sc目录为生产部存储目录只能对生产部人员可以写入,并且生产部人员该目录所建立的文件都自动归属到

3)/cw目录为财务部存储目录只能对财务部人员可以写入并且财务部人员所建立的文件都自动属于caiwu组中

4) admin用户对于/sc和/cw目录可以读,写,执行

[root@456 ~]# mkdir /pub
[root@456 ~]# mkdir /sc
[root@456 ~]# mkdir /cw
[root@456 ~]# useradd admin
[root@456 ~]# chmod ugo+rwx /pub
[root@456 ~]# chmod 1777 /pub
[root@456 ~]# ls -ld /pub
drwxrwxrwt. 2 root root 6 Jun 19 02:13 /pub
[root@456 ~]# groupadd shengchanzu
[root@456 ~]# ls -ld /sc
drwxr-xr-x. 2 root root 6 Jun 19 02:13 /sc
[root@456 ~]# chgrp shengchanzu /sc
[root@456 ~]# ls  -ld /sc
drwxr-xr-x. 2 root shengchanzu 6 Jun 19 02:13 /sc
[root@456 ~]# chmod 2770 /sc
[root@456 ~]# ls -ld /sc
drwxrwsr-x. 2 root shengchanzu 6 Jun 19 02:13 /sc
[root@456 ~]# chgrp caiwu /cw
[root@456 ~]# chmod 2770 /cw
[root@456 ~]# ls -ld /cw
drwxrwsr-x. 2 root caiwu 6 Jun 19 02:13 /cw
[root@456 ~]# setfacl -m u:admin:rwx /sc/
[root@456 ~]# setfacl -m u:admin:rwx /cw/
[root@456 ~]# ll -d /sc/
drwxrwsr-x+ 2 root shengchanzu 6 Jun 19 02:13 /sc/
[root@456 ~]# getfacl /sc /cw
getfacl: Removing leading '/' from absolute path names
# file: sc
# owner: root
# group: shengchanzu
# flags: -s-
user::rwx
user:admin:rwx
group::rwx
mask::rwx
other::r-x
default:user::rwx
default:user:admin:rwx
default:group::rwx
default:mask::rwx
default:other::r-x

# file: cw
# owner: root
# group: caiwu
# flags: -s-
user::rwx
user:admin:rwx
group::rwx
mask::rwx
other::r-x
default:user::rwx
default:user:admin:rwx
default:group::rwx
default:mask::rwx
default:other::r-x




 2、设置特殊权限,要求如下:

1)创建目录/test/data,让it组内普通用户对其有写权限,且创建的所有文件的属组为目录所属的组,此外,每个用户仅能删除自己的文件 

[root@456 ~]# groupadd it
[root@456 ~]# mkdir -p /test/data
[root@456 ~]# chown :it /test/data
[root@456 ~]# chmod o+t /test/data   
[root@456 ~]# chmod g+ws /test/data
[root@456 ~]# ls -ld /test/data
drwxrwsr-t. 2 root it 6 Jun 19 06:27 /test/data

2)让普通用户能使用/tmp/cat去查看/etc/shadow文件

[root@456 ~]# su - redhat
[redhat@456 ~]$ su
Password: 
[root@456 redhat]# chmod u+s /bin/cat
[root@456 redhat]# su - redhat
[redhat@456 ~]$ cat /etc/shadow
root:$6$taORkoBps.TexkpZ$Q4GNrS0wL.YfMRMolxIOLm.DmnHgVQumrIEiVGSCV2kYxFEPD6uTAQxZsfnUXmFXU3uqQmCPuno0WtU/ewYiG1:19157:0:99999:7:::
bin:*:18367:0:99999:7:::
daemon:*:18367:0:99999:7:::
adm:*:18367:0:99999:7:::
lp:*:18367:0:99999:7:::
sync:*:18367:0:99999:7:::
shutdown:*:18367:0:99999:7:::

3、设置ACL权限,要求如下:

​ 在/test/dir里创建的新文件自动属于webs组,

  组apps的成员如:tomcat能对这些新文件有读写权限,

  组dbs的成员如:mysql只能对新文件有读权限,

  其它用户(不属于webs,apps,dbs)不能访问这个文件夹。

[root@456 ~]# groupadd webs
[root@456 ~]# groupadd apps
[root@456 ~]# groupadd dbs
[root@456 ~]# useradd tomcat
[root@456 ~]# useradd mysql
[root@456 ~]# gpasswd -a tomcat apps
Adding user tomcat to group apps
[root@456 ~]# gpasswd -a mysql dbs
Adding user mysql to group dbs
[root@456 ~]# mkdir -p /test/dir
[root@456 ~]# chgrp -R webs /test/dir
[root@456 ~]# chmod -R g+s /test/dir
[root@456 ~]# setfacl -R -m g:apps:rw /test/dir
[root@456 ~]# setfacl -R -m g:dbs:r /test/dir
[root@456 ~]# setfacl -R -m o=  /test/dir
[root@456 ~]# ll -d /test/dir
drwxrws---+ 2 root webs 6 Jun 19 07:20 /test/dir

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值