8月2日作业

        1、在/data/testdir里创建的新文件自动属于g1组,组g2的成员如:alice能对这些新文件有读写权限,组g3的成员如:tom只能对新文件有读权限,其它用户(不属于g1,g2,g3)不能访问这个文件夹。

[root@localhost testdir]# groupadd g1
[root@localhost testdir]# groupadd g2
[root@localhost testdir]# groupadd g3
[root@localhost testdir]# mkdir -p /date/testdir
[root@localhost testdir]# chmod 770 /date/testdir
[root@localhost testdir]# chown :g1 /date/testdir
[root@localhost testdir]# useradd -G g2 alice
[root@localhost testdir]# useradd -G g3 tom
[root@localhost testdir]# setfacl -Rm g:g2:rwx /date/testdir/
[root@localhost testdir]# setfacl -Rm g:g3:rx /date/testdir/
[root@localhost testdir]# getfacl /date/testdir/
getfacl: Removing leading '/' from absolute path names
# file: date/testdir/
# owner: root
# group: g1
user::rwx
group::rwx
group:g2:rwx     //题目要求读写,没有x权限也不行
group:g3:r-x     //题目要求读权限,如果没有x权限是不能读的
mask::rwx
other::---

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 ~]# gpasswd sales
Changing the password for group sales
New Password: 
Re-enter new password: 
[root@localhost ~]# useradd -G sales user1
[root@localhost ~]# useradd -G sales user2
[root@localhost ~]# useradd -G sales user3
[root@localhost ~]# gpasswd -A user2 sales
[root@localhost ~]# usermod -g sales user1
[root@localhost ~]# su - user1
[user1@localhost ~]$ touch user1.txt
[user1@localhost ~]$ ls -l user1.txt 
-rw-r--r-- 1 user1 sales 0 Jul 25 12:28 user1.txt   //查看user1创建文件默认属组为sales
[user1@localhost ~]$ exit
logout
[root@localhost ~]# su user2
[user2@localhost root]$ 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

原创文章,作者:Lii,如若转载,请注明出处:http://www.178linux.com/28428

赞 (0)
LiiLii
上一篇 2016-08-05 16:20
下一篇 2016-08-05 21:42

相关推荐

  • N25-第五周作业

    第五周 1、显示/boot/grub/grub.conf中以至少一个空白字符开头的行; [root@zf ~]# grep -E "^[[:space:]]+[[:alnum:]]+" /boot/grub/grub.conf     &n…

    Linux干货 2016-12-26
  • shell脚本基础

    1、编程基础     程序:指令+数据   程序编程风格:                         过程式:以指令为中心,数据服务于指令         &nbs…

    2017-04-20
  • N26-第二周博客作业

    一、Linux上的文件管理类命令都有哪些,其常用的使用方法及其相关示例演示。 一) 目录管理命令 1. cd :用于切换目录。命令格式为:cd dirname 命令使用技巧: ~]# cd 进入用户主目录 ~]# cd – 进入上一次所在目录 ~]# cd / 进入根目录 ~]# cd ~ 进入用户主目录 ~]# cd .. 返回上一级…

    2017-03-01
  • linux-第一周

    inux命令:(type)                  1,集成在bash中的命令,内部命令。依赖于shell类型。                  2,在文件系统路径下有…

    Linux干货 2017-05-20
  • 第十四周作业

    系统的INPUT和OUTPUT默认策略为DROP; [root@CentOS7 ~]# iptables -P INPUT DROP [root@CentOS7 ~]# iptables -P OUTPUT DROP 1、限制本地主机的web服务器在周一不允许访问;新请求的速率不能超过100个每秒;web服务器包含了admin字符串的页面不允许访问;web服…

    Linux干货 2017-08-13
  • Linux运维学习历程-第十天-文件查找工具

    概述:本篇主要讲解locate命令和find命令,来帮助我们在linux中完成文件查找,方便我们快速定位文件。 一、文件查找    即在文件系统上查找符合条件的文件,常用工具有locate和find  1、locate命令    locate命令其实是find -name的另一种写法,但是要比后者快得多,原因…

    Linux干货 2016-08-21