Linux组的创建与权限的创建与修改

1.[root@localhost ~]# groupadd g1
[root@localhost ~]# useradd redhat
[root@localhost ~]# touch /redhat.txt
[root@localhost ~]# chown redhat:g1 /redhat.txt
[root@localhost ~]# ll -d /redhat.txt
-rw-r--r--. 1 redhat g1 0  4月 26 20:19 /redhat.txt

2.[root@localhost ~]# mkdir /sc
[root@localhost ~]# groupadd group
[root@localhost ~]# chown :group /sc
[root@localhost ~]# chmod 070 /sc
[root@localhost ~]# groupmod -M redhat group

[root@localhost ~]# gpasswd -M redhat group
[root@localhost ~]# useradd helen
[root@localhost ~]# su - redhat
[redhat@localhost ~]$ touch /sc/1
[redhat@localhost ~]$ su - helen
[helen@localhost ~]$ touch /sc/2
touch: 无法创建 '/sc/2': 权限不够
3.[root@localhost ~]# mkdir /cw
[root@localhost ~]# groupadd mygroup
[root@localhost ~]# chown :mygroup /cw
[root@localhost ~]# chmod g+s /cw
[root@localhost ~]# chmod 070 /cw
[root@localhost ~]# gpasswd -M redhat mygroup
[root@localhost ~]# su - redhat
[redhat@localhost ~]$ touch /cw/1
[redhat@localhost ~]$ exit
注销
[root@localhost ~]# su - helen
[helen@localhost ~]$ touch /cw/2
touch: 无法创建 '/cw/2': 权限不够
[helen@localhost ~]$ exit
注销
[root@localhost ~]# ll -d /cw
d---rws---. 2 root mygroup 15  4月 26 20:33 /cw
[root@localhost ~]# ll -d /cw/
d---rws---. 2 root mygroup 15  4月 26 20:33 /cw/
[root@localhost ~]# ll -d /cw/1
-rw-r--r--. 1 redhat mygroup 0  4月 26 20:33 /cw/1
[root@localhost ~]# 

4.[root@localhost ~]# setfacl -m u:helen:rwx /cw /sc
[root@localhost ~]# su - helen
[helen@localhost ~]$ touch /cw/2
[helen@localhost ~]$ touch /sc/2

5.[root@localhost ~]# mkdir /test
[root@localhost ~]# chmod 777 /test
[root@localhost ~]# chmod o+t /test
[root@localhost ~]# touch /test/1
[root@localhost ~]# su - redhat
[redhat@localhost ~]$ touch /test/2
[redhat@localhost ~]$ su - helen

[root@localhost ~]# su - helen
[helen@localhost ~]$ touch /test/3
[helen@localhost ~]$ rm -rf /test
rm: 无法删除 '/test/1': 不允许的操作
rm: 无法删除 '/test/2': 不允许的操作
6.[root@localhost ~]# groupadd temp
[root@localhost ~]# mkdir /test/dir
[root@localhost ~]# chown :temp /test/dir/
[root@localhost ~]# chmod g+s /test/dir
[root@localhost ~]# touch /test/dir/1
[root@localhost ~]# ll -d /test/dir/1
-rw-r--r--. 1 root temp 0  4月 26 20:42 /test/dir/1

  • 5
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值