用户权限以及组权限作业

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

相关推荐

  • 0808文本处理作业

                           1 、删除/etc/grub2.conf 文件中所有以空白开头的行行首的空白字符。 答:sed  ‘@^[[:space]]\+@@’  /etc/grub2/cf…

    Linux干货 2016-08-11
  • Linux-系统启动的基本过程 以及相关破环修复实验。

    这章简单描述下系统的启动流程,主要以破环修复实验为主: 系统启动基本过程:       Linux系统启动过程大致按照如下步骤进行(这是一个简述):        第一阶段:BIOS启动引导阶段;       …

    2017-07-10
  • PHP中引用的详解(引用计数、写时拷贝)

    《PHP5中文手册》内容中"引用的解释"一文的摘要: 1. PHP中引用的特性 PHP中引用意味着用不同的名字访问同一个变量内容,引用不是C的指针(C语言中的指针里面存储的是变量的内容,在内存中存放的地址),是变量的另外一个别名或者映射。注意在 PHP 中,变量名和变量内容是不一样的,因此同样的内容可以有不同的名字。最接近的比喻是 Uni…

    Linux干货 2015-04-10
  • Linux系统性能工具

    linux中几款常用的系统性能分析工具: 1.vmstat命令 解释: 虚拟内存信息 用法: vmstat [options] [delay [count]] vmstat 2 5 //每2秒刷新一次,一共刷新5次 输出属性: procs: r:可运行(正运行或等待运行)进程的个数,和核心数有关 b:处于不可中断睡眠态的进程个数(被阻塞的队列的长度) mem…

    Linux干货 2017-12-19
  • 计算机相关简介和linux相关简介

    一、计算机相关简介与linux的一些概念 计算机系统 由硬件(Hardware)系统和软件(Software)系统两大部分构成: 硬件系统 :CPU(控制器、运算器),内存储器(RAM、ROM),外存储器(硬盘等),输入设备(键盘、鼠标等),输出设备(显示器等),其他设备相关设备。  软件系统 :系统软件(操作系统,数…

    Linux干货 2017-02-18
  • 大数据计算:如何仅用1.5KB内存为十亿对象计数

    Big Data Counting: How To Count A Billion Distinct Objects Using Only 1.5K This is a guest post by Matt Abrams (@abramsm), from Clearspring, discussing how they are able to accurat…

    Linux干货 2015-04-08