用户权限以及组权限作业

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

相关推荐

  • hbase安装配置(整合到hadoop)

    1.  快速单击安装 在单机安装Hbase的方法。会引导你通过shell创建一个表,插入一行,然后删除它,最后停止Hbase。只要10分钟就可以完成以下的操作。 1.1下载解压最新版本 选择一个 Apache 下载镜像:http://www.apache.org/dyn/closer.cgi/hbase/,下载 HBase Re…

    Linux干货 2015-04-13
  • 马哥教育网络班22期+第8周课程练习 忍者乱太郎喻成

    第八周 1、请描述网桥、集线器、二层交换机、三层交换机、路由器的功能、使用场景与区别。 一个好的链接,主要的参考http://www.cnblogs.com/imapla/archive/2013/03/12/2955931.html简单的总结和自己的理解桥接器(network bridge),又称网桥,一种网络设备,负责网络桥接(network …

    Linux干货 2016-12-26
  • lvs-dr实践-week17

    1、结合图形描述LVS的工作原理; lvs工作流程: ipvs是工作于input链上,监听目标地址上对应的目标端口,如果这个端口对应的服务定义为集群服务, 就强行修改报文的流程,完成转发, 通过postrouting送出去, 为了让后端主机能够接收, 此时需要让RS也具有目标ip地址, 要么修改目标ip地址支持基于TCP,UDP,SCTP,AH,EST,AH…

    2017-05-23
  • 1017作业

    1 生产环境发现一台服务器系统时间产生偏差,造成服务异常,请帮忙校正 ##先分析硬件时间不对还是系统时间不对,如果是系统时间不对: [root@localhost ~]# hwclock -w [root@localhost ~]#  ##如果是硬件时间不对: [root@localhost ~]#…

    Linux干货 2016-10-18
  • vim简单操作

    vim第一讲 光标在屏幕文本中的移动既可以用箭头键,也可以使用 hjkl 字母键。 h (左移) j (下行) k (上行) l (右移) 欲进入 Vim 编辑器(从命令行提示符),请输入:vim 文件名 <回车> 欲退出 Vim 编辑器,请输入 <ESC> :q! <回车> 放弃所有改动。 或者输入 <ESC&gt…

    Linux干货 2017-07-29
  • 马哥教育网络班N22期+第6周课程练习

    一、总结vim编辑器的使用方法 vim文本编辑器 全屏编辑器,模式化编辑器 vim的教程文件命令:vimtutor vim /path/to/somefile vim模式: 编辑模式(命令模式),默认模式 输入模式 末行模式 内置的命令行接口; 模式转换: 编辑模式—>输入模式: i:insert, 在光标所在处前方输入,转为输入模式 a:append…

    Linux干货 2016-10-09