权限练习1

本文详细介绍了如何在Linux系统中创建用户组,设置文件和目录权限,包括chown、chgrp、chmod、setfacl等命令的应用,以及如何实现特定用户对特定目录的访问控制。
摘要由CSDN通过智能技术生成

#1、创建g1组,要求创建一个属于redhat用户g1组的文件redhat.txt

mkdir g1

touch /root/redhat.txt

useradd redhat

chown redhat:g1 /root/redhat.txt
#2、新建/sc目录,所属组为group组,root用户和group组用户可在该目录下创建文件,其他人无任何权限

mkdir /sc

groupadd group

chown  :group /sc

ll -d /sc

setfacl -m g:group:rwx /sc

setfacl -m o:--- /sc
#3、新建/cw目录为财务部存储目录,只能对财务部人员可以写入,并且财务部人员所建立的文件都自动属于mygroup组中

mkdir /cw

groupadd mygroup

chown  :mygroup /cw

ll -d /cw

chmod g+w /cw

chmod g+s /cw

ll -d /cw

useradd ma1

useradd ma2

useradd ma3

gpasswd -M ma1,ma2,ma3 mygroup

touch /cw/1

su - ma1

touch /cw/1

ll /cw
#4、设置helen用户对于/sc和/cw目录可读、可写、可执行

useradd helen

setfacl -m u:helen:rwx /sc

setfacl -m u:helen:rwx /cw
#5、设置/test目录为公共存储目录,对所有用户可以读、写、执行,但用户只能删除属于自己的文件。

mkdir /test

ll /test -d

chmod 777 /test

ll -d /test

chmod u+t /test

ll -d /test

touch /test/1

su - helen

rm -rf /test/1


#6、在/test/dir里创建的新文件自动属于temp组

mkdir /test/dir

groupadd temp

ll -d /test/dir 

chown  :temp /test/dir

touch /test/dir/1

chmod o+w /test/dir

chmod g+s /test/dir

ll -d /test/dir

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值