用户权限以及组权限作业

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

相关推荐

  • 带你走进PI的世界-Raspbian Pi上实现LAMP

     初识   Raspbian PI                   前段时间,出于兴趣,入手一个树莓派(Raspbian PI…

    Linux干货 2016-01-05
  • 硬链接和软链接的说明

    1、硬链接和软链接的区别    (1)、原理上:                   【1】 硬链接(hard link):                 &…

    2017-07-21
  • sed与vim浅析

    sed与vim sed Stream EDitor, 行编辑器,sed是一种流编辑器,它一次处理一行内容。处理时,把当前处理的行存储在临时缓冲区中,称为“模式空间”( pattern space),接着用sed命令处理缓冲区中的内容,处理完成后,把缓冲区的内容送往屏幕。接着处理下一行,这样不断重复,直到文件末尾。文件内容并没有改变,除非你使用重定向存储输出。…

    Linux干货 2016-08-10
  • 一次css页面加载异常的折腾

    1       原始需求 近期在搭建平台,因多域名会分割流量,所以希望将类似 ansible.178linux.com  salt.178linux.com qa.178linux.com 这些平台整合为一个平台,所示如下 ansible.178linux.com =è www.178li…

    系统运维 2015-06-10
  • Apc缓存Opcode

    1、PHP执行 PHP的运行阶段也分成三个阶段: Parse。语法分析阶段。 Compile。编译产出opcode中间码。 Execute。运行,动态运行进行输出。                            …

    Linux干货 2015-04-10
  • rpm数据库损坏 不能使用正常使用yum的处理方法

           不知道有没有跟我一样的小伙伴,在使用yum安装软件时,发现无法正常使用yum安装软件包,下面出现几句英语提示。在使用rpm时也无法正常的使用。其实 是rpm数据库崩溃导致的 下面就简单的介绍一下怎么回复,让其正常的工作,很简单几个命了即可。 1. 出现错误提示,这时我们需要认真的阅读下面的提示,不要乱找原…

    Linux干货 2017-06-13