用户权限以及组权限作业

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

[root@localhost testdir]# mkdir -p /data/testdir
[root@localhost testdir]# groupadd g1
[root@localhost testdir]# groupadd g2
[root@localhost testdir]# groupadd g3
[root@localhost testdir]# chgrp g1 /data/testdir
[root@localhost testdir]# useradd -G g2 alice
[root@localhost testdir]# useradd -G g3 tom
[root@localhost testdir]# chmod g+s /data/testdir
[root@localhost testdir]# setfacl -Rm d:g:g2:rwx /data/testdir
[root@localhost testdir]# setfacl -Rm d:g:g3:r /data/testdir
[root@localhost testdir]# getfacl /data/testdir

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 ~]# echo centos > gpasswd --stdin sales
[root@localhost ~]# gpasswd -A user2 sales
[root@localhost ~]# usermod -g sales user1
[root@localhost ~]# gpasswd -a user1 sales
[root@localhost ~]# gpasswd -a user2 sales
[root@localhost ~]# gpasswd -a user3 sales
[root@localhost ~]# su - user1
Last login: Sat Aug  6 15:28:56 CST 2016 on pts/0
[user1@localhost ~]$ touch a.txt
[user1@localhost ~]$ ll !$
ll a.txt
-rw-r--r--. 1 user1 sales 0 Aug  6 15:38 a.txt
[user1@localhost ~]$ exit
logout
[root@localhost ~]# su - user2
Last login: Fri Aug  5 21:37:49 CST 2016 on pts/0
[user2@localhost ~]$ 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
[root@localhost ~]# tail -3 /etc/passwd 
wangcai:x:1006:1006::/home/wangcai:/bin/bash
gentoo:x:1007:1007:Gentoo Distribution:/home/gentoo:/bin/csh
user3:x:1010:1010::/home/user3:/bin/bash
[root@localhost ~]# tail -3 /etc/group
g3:x:3003:
user1:x:1008:
user3:x:1010:

原创文章,作者:皱 多利亚,如若转载,请注明出处:http://www.178linux.com/29861

(0)
皱 多利亚皱 多利亚
上一篇 2016-08-08 16:14
下一篇 2016-08-08 16:15

相关推荐

  • 计划任务

    任务计划Linux任务计划、周期性任务执行未来的某时间点执行一次任务:atbatch:系统自行选择空闲时间去执行此处指定的任务周期性运行某任务:cron     at任务at命令:at [option] TIME常用选项:-V 显示版本信息:-l: 列出指定队列中等待运行的作业;相当于atq-d: 删除指定的作业;相当于atrm-c: 查…

    Linux干货 2017-08-28
  • C语言结构体里的成员数组和指针

    单看这文章的标题,你可能会觉得好像没什么意思。你先别下这个结论,相信这篇文章会对你理解C语言有帮助。这篇文章产生的背景是在微博上,看到@Laruence同学出了一个关于C语言的题,微博链接。微博截图如下。我觉得好多人对这段代码的理解还不够深入,所以写下了这篇文章。 为了方便你把代码copy过去编译和调试,我把代码列在下面: final void&n…

    Linux干货 2016-05-29
  • 计算机基础知识(第一天)

    一、计算机的硬件组成         冯诺依曼体系结构:             CPU、存储器、输入设备、输出设备       &nbsp…

    Linux干货 2016-07-26
  • 2016-10-17作业

    1 生产环境发现一台服务器系统时间产生偏差,造成服务异常,请帮忙校正。 date命令查看系统时间,clock或者hwclock命令查看硬件时间, 将系统时间同步到硬件时间的方法hwclock -s   2 生产有一个数据同步脚本需要执行很长时间,怎样做到无人值守,在管理工具退出的情况下,脚本依然能正常运行。在生产环境的中创建SCREEN会话,会话的…

    Linux干货 2016-10-18
  • Linux文件查找命令详解

    Linux中在文件系统上查找符合条件的文件,实现工具有locate和find locate: 1.它是依赖于事先索引构建好的数据库进行查找的。更新它的数据库有两种方式,一种是系统定期自动更新,另一种是执行命令updatedb手动更新数据库。 注意:索引构建过程需要遍历整个根文件系统,极消耗资源 2.它的工作特性: 1.因为是基于数据库实现的,所以查找速度快(…

    Linux干货 2017-04-10