8月2日作业

        1、在/data/testdir里创建的新文件自动属于g1组,组g2的成员如:alice能对这些新文件有读写权限,组g3的成员如:tom只能对新文件有读权限,其它用户(不属于g1,g2,g3)不能访问这个文件夹。

[root@localhost testdir]# groupadd g1
[root@localhost testdir]# groupadd g2
[root@localhost testdir]# groupadd g3
[root@localhost testdir]# mkdir -p /date/testdir
[root@localhost testdir]# chmod 770 /date/testdir
[root@localhost testdir]# chown :g1 /date/testdir
[root@localhost testdir]# useradd -G g2 alice
[root@localhost testdir]# useradd -G g3 tom
[root@localhost testdir]# setfacl -Rm g:g2:rwx /date/testdir/
[root@localhost testdir]# setfacl -Rm g:g3:rx /date/testdir/
[root@localhost testdir]# getfacl /date/testdir/
getfacl: Removing leading '/' from absolute path names
# file: date/testdir/
# owner: root
# group: g1
user::rwx
group::rwx
group:g2:rwx     //题目要求读写,没有x权限也不行
group:g3:r-x     //题目要求读权限,如果没有x权限是不能读的
mask::rwx
other::---

2、创建组sales,gid 3000,passwd:centos,sales admins:user2

将用户user1,user2,user3加入到sales辅助组

希望user1 创建新文件 默认的所属组为sales

user2将用户user3从sales组移除

删除sales,user1,user2

[root@localhost ~]# groupadd -g 3000 sales
[root@localhost ~]# gpasswd sales
Changing the password for group sales
New Password: 
Re-enter new password: 
[root@localhost ~]# useradd -G sales user1
[root@localhost ~]# useradd -G sales user2
[root@localhost ~]# useradd -G sales user3
[root@localhost ~]# gpasswd -A user2 sales
[root@localhost ~]# usermod -g sales user1
[root@localhost ~]# su - user1
[user1@localhost ~]$ touch user1.txt
[user1@localhost ~]$ ls -l user1.txt 
-rw-r--r-- 1 user1 sales 0 Jul 25 12:28 user1.txt   //查看user1创建文件默认属组为sales
[user1@localhost ~]$ exit
logout
[root@localhost ~]# su user2
[user2@localhost root]$ gpasswd -d user3 sales
Removing user user3 from group sales
[user2@localhost ~]$ exit
logout
[root@localhost ~]# userdel -r user1     //删除用户
userdel: group user1 not removed because it is not the primary group of user user1.
[root@localhost ~]# userdel -r user2
[root@localhost ~]# groupdel sales

原创文章,作者:Lii,如若转载,请注明出处:http://www.178linux.com/28428

(0)
LiiLii
上一篇 2016-08-05 16:20
下一篇 2016-08-05 21:42

相关推荐

  • N22-妙手-第七周课程练习

    1、创建一个10G分区,并格式为ext4文件系统;    (1) 要求其block大小为2048, 预留空间百分比为2, 卷标为MYDATA, 默认挂载属性包含acl; [root@localhost ~]# mke2fs -t ext4 -m 2 -L MY…

    Linux干货 2016-10-09
  • shell脚本编程进阶

    一些常用的编程语句,

    2017-12-23
  • Linux创建CA和申请认证

    Linux创建CA和申请认证 背景: 在学习Linux运维中,学习到了CA的创建和申请认证,为了加深对CA的理解,这里做一个创建CA和申请认证的实验并记录下来供以后回顾。 介绍: 什么是CA认证? 电子商务认证授权机构(CA, Certificate Authority),也称为电子商务认证中心,是负责发放和管理数字证书的权威机构,并作为电子商务交易中受信任…

    2017-09-09
  • 马哥教育网络班20期+第一周课程练习

    一、计算机的组成及其功能。 计算机是由几个单元所组成,输入单元,输出单元,运算器,控制器,存储器,5大单元组成  1、运算器 又称运算器又称算术逻辑单元,它是计算机对数据进行加工处理的部件,包括算术运算(加、减、乘、除等)和逻辑运算(与、或、非、异或、比较等)。 2、控制器 负责从存储器中取出指令,并对指令进行译码;根据指令的要求,按时间的先后顺序…

    Linux干货 2016-06-23
  • 用户组和权限管理知识总结

    在介绍本期内容之前呢,有一个小插曲.就是由于昨天晚上我没有正常关闭虚拟机,今天早上打开的时候一直显示正在使用中,弹 出来个小框框,如下图,马赛克部分呢就是提示的路径,安装路径不一样,提示的就也不一样. 此虚拟机似乎正在使用中。 如果此虚拟机已在使用中,请按“取消”按钮,以免损坏它。如果此虚拟机未使用,请按“取得所有权(T)”按钮以获取它的所有权。&…

    2017-07-28
  • NFS服务

    NFS服务:       NFS:Network File System 网络文件系统,基于内核的文件系统。 Sun公司开发,通过使用NFS,用户和程序可以像访 问本地文件一样访问远端系统上的文件,基于RPC(Remote Procedure Call Protocol远程过程调用)实现 。 RPC采用C/S模式。客户机请求程序…

    2017-08-14