用户权限以及组权限作业

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
下一篇 2016-08-08

相关推荐

  • 马哥教育网络班19期+第7周课程练习

    1.创建一个10G分区,并格式为ext4文件系统:   (1)要求其block大小为2048,预留空间百分比为2,卷标为MYDATA,默认挂载属性包含acl;   (2)挂载至/data/mydata目录,要求挂载时禁止程序自行运行,且不更新文件的访问时间戳;   fdisk /dev/sdb    part…

    Linux干货 2016-06-22
  • 常见的文本处理工具及正则表达式的相关知识

    1.cat命令使用详解 cat [option]… [file]… -A equivalent=vET -b 非空行编号 -E 行为显示$ -n 显示所有行的行号 -s 行号并压缩连续空行为一行 -T 显示tab为^M 实例:显示a文件的行号及所有控制符 2.(1)head使用详解 head -n x 显示前x行 head -c x …

    Linux干货 2016-08-07
  • N24_jerry 第十二周作业

    1、请描述一次完整的http请求处理过程; 简介 一次完整的HTTP请求过程从TCP三次握手建立连接成功后开始,客户端按照指定的格式开始向服务端发送HTTP请求,服务端接收请求后,解析HTTP请求,处理完业务逻辑,最后返回一个HTTP的响应给客户端,HTTP的响应内容同样有标准的格式。无论是什么客户端或者是什么服务端,大家只要按照HTTP的协议标准…

    Linux干货 2017-03-22
  • 我的第一篇博客

        对于一个连日记都懒得写的人来说,写博客博客还真是一个难题。但是为了能让自己有所进步有所提高、更是为了记录自己逐步成长的过程,还是下定决心记录下在接下来的日子里的点点滴滴。当然,这点点滴滴指的是 —— 知识     我想刚学linux的新手眼里除了图形化就只有黑白两种颜色了吧!但是为了提高自己…

    Linux干货 2017-07-15
  • 网络班26期-第1周课程作业

    1、描述计算机的组成及其功能? (1)CPU:计算机的大脑,计算机的运算,命令的控制功能,寄存器及缓存都由CPU功能承担; (2)内存:RAM,随机访问存储器,计算机的另一个核心功能,系统指令存放及运行的基础。 (3)输入设备:人工给计算机下指令的设备,例如鼠标,键盘等; (4)输出设备:计算机输出人工输入的执行命令的结果;例如,音响,显示屏等; …

    Linux干货 2017-01-10
  • Nginx+resin调优文档[原创]

    为什么不选择Apache/mod+resin?       前面一直使用该模式,mod_caucho暴露源码的bug一直未得到彻底的解决。因此切换到Nginx+resin平台。硬件上要求除了内存一定要足够大(建议>4G),无其它要求(当然也不能太破,呵呵)。操作系统强烈要求安装64位,32位操…

    Linux干货 2015-03-27