用户权限以及组权限作业

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

相关推荐

  • 使用groupmems -l -g 组名选项遇到的问题

    groupmems -l -g 组名 显示的不是附加组的成员,而是显示的是/etc/group文件的最后一个字段的内容

    Linux干货 2017-11-23
  • N25-第十二周博客作业

    1、请描述一次完整的http请求处理过程; (1) 建立或处理连接:接收请求或拒绝请求;(2) 接收请求:接收来自于网络上的主机请求报文中对某特定资源的一次请求的过程;(3) 处理请求:对请求报文进行解析,获取客户端请求的资源及请求方法等相关信息;(4) 访问资源:获取请求报文中请求的资源;从磁盘中获取(5) 构建响应报文:(6) 发送响应报文:(7) 记录…

    Linux干货 2017-04-09
  • 使用NFS和Samba文件服务搭建博客站点

    使用NFS和Samba文件服务搭建博客站点 实验目的:分别使用NFS和Smaba文件服务实现wordpress 实验要求: (1) server导出/data/application/web,在目录中提供wordpress; (2) client挂载nfs server导出的文件系统至/var/www/html;(3) 客户端1(lamp),部署w…

    2017-04-30
  • 为什么中国的网页设计那么烂?

    Nick Johnson,一个有12年经验的Web设计师在它的blog里写下了“Why is Chinese Web Design So Bad”,新浪,人人,百度,阿里巴巴,腾讯榜上有名。其中的观点相当的好,希望所有的中国人都读一下。我不全文翻译了,只是给大家看一些摘要。(保证不会像《环球时报》一样) —————————— 作者2005年的夏天来到中国,他…

    Linux干货 2016-07-11
  • 2016年8月6日作业练习

    练习: 1、显示/proc/meminfo文件中以大小s开头的行;(要求:使用两种方式) [root@localhost ~]# grep -i "^[sS]" /proc/meminfo SwapCached:      &nb…

    Linux干货 2016-08-07
  • LVS调度方法

    lvs scheduler:     根据其调度时是否考虑后端主机的当前负载,可分为静态方法和动态方法     静态方法:仅根据算法本身进行调度:         RR:Round Ronin 轮询         WRR:Weighted…

    Linux干货 2017-01-10