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

相关推荐

  • Shell脚本编程(上)

        Shell脚本编程基础 Shell 脚本基础:包含一些命令或声明并符合一定格式的文本文件Shell 脚本用途:        1. 自动化常用命令        2. 执行系统管理和故障排除        3. …

    2017-04-16
  • 搭建个人博客&论坛(LAMP):wordpress、discuz、phpMyAdmin

    搭建个人博客&论坛(LAMP):wordpress、discuz、phpMyAdmin 一、快速部署LAMP架构平台 1.CentOS 6系统部署 所需安装包:httpd, php, mysql-server, php-mysql ]# yum install -y  httpd php&n…

    Linux干货 2016-10-17
  • 计算机组成原理

    计算机组成原理 计算机概述 计算机的基本组成: ·         存储器:     实现记忆功能的部件用来存放计算程序及参与运算的各种数据 ·         运算器:     负责数据的算术运算和…

    Linux干货 2016-10-31
  • 网络班N22期第二周博客作业

    一、Linux常用文件管理命令及用法。  (1)、cat,由第一行开始显示内容,并将所有内容输出     用法:cat [OPTION]… [FILE]…      常用选项:     &nbsp…

    Linux干货 2016-08-22
  • grep用法

    一、前言 grep是功能强大的文本处理工具,全称:global search regular expression and print out the line,grep一行一行使用正则表达式匹配文本,之后对匹配到的文本整行显示(除非使用特定的选项取反,如 grep -v)。 二、grep用法 grep命令用法:    &nbs…

    Linux干货 2015-08-24
  • 压缩和解压缩总结

                      压缩和解压缩的命令很多,今天总结如下: gzip  压缩比1–9  默认是6  压缩比越高  耗费CPU资源也多,文件比较小的话,不建议使用gzip压缩,因为使用gzip越压缩越大。…

    Linux干货 2017-04-17