用户权限以及组权限作业

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 系统架构

    1.内核     1.1.组成部分         1.1.1.系统调用接口         1.1.2.进程管理 &n…

    Linux干货 2016-06-04
  • 内核参数修改 内核编译 第14天

    Linux内核:单内核,模块化 内核的某些模块 编译进内核本体 [*] 编译成内核模块 [M] 不选择使用     [ ] 内核的组成部分 /boot/vmlinuz-VERSION /lib/modules/VERSION/ *.ko 模块间有可能有依赖关系 内核模块管理 lsmod:显…

    Linux干货 2016-01-18
  • LVM原理、创建、扩容、缩减、快照详解

    LVM是什么?为什么要使用LVM?     LVM(Logical Volume Manager):逻辑卷管理, 在日常使用或生产环境中, 我们可能会因为在规划存储时未考虑到未来数据增长的速度超乎我们的预计而措手不及,因为增加一块硬盘再将源数据移到新硬盘上很麻烦并且提高了成本还浪费硬盘空间。   &…

    Linux干货 2016-03-09
  • 逻辑卷管理工具lvm2

    lvm2:location Volume Manage Version 2 linux支持逻辑卷的模块为dm模块                        dm模块是将一个或多个底层物理设备组织成一个逻辑设备的模块。 在CentOS中,…

    Linux干货 2016-03-27
  • 文本编辑工具Sed

                    Stream EDitor, 行编辑器         sed是一种流编辑器,它一次处理一行内容。处理时,一次性的先把文件读入内存中,并且开辟一块内存空间,该内存空间称为“模式空间”(pa…

    Linux干货 2016-08-10
  • 一键编译安装httpd服务

    一键编译安装httpd服务 背景: httpd服务是一个常用的web服务,所以很多地方会用到,这里写一个一键编译安装httpd服务的脚本。 环境: 系统:centos6.9和centos7.3(应该所有的6和7的版本都可以使用) httpd源代码版本:httpd-2.2.34.tar.bz2和httpd-2.4.27.tar.bz2 。下载网址官网:http…

    2017-09-16