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

相关推荐

  • linux中文本处理工具

      对于linux来讲,文本处理是非常重要的,因为linux系统就是由无数的文件组成的,linux中一切皆文件。文件的处理方式有很多种,所以就有众多的文本处理工具,各自作用于不同的文本处理方式。 一、查看文件命令:    cat命令:处理显示文件内容,不改变原文件    cat命令常用于查看文件内容,也可通过…

    Linux干货 2016-08-08
  • 文本编辑器vim概述与应用示例

    文本编辑器vim概述与应用示例 文本编辑器概述 vim编辑器是一种易用、功能强大的文本编辑器,可以基于三种不同的模式对文本进行编辑,包括编辑模式、输入模式和末行模式。 编辑模式 模式转换 i 表示在光标所在处插入 a 表示在光标后方插入 o 表示在光标所在处的下一行插入 O 表示在光标所在处的上一行插入 I 表示在光标所在行的行首插入 A 表示在光标所在行的…

    Linux干货 2017-08-06
  • 网络配置——CentOS7

    CentOS 7 网络属性配置 使用传统命名方式: (1) 编辑/etc/default/grub 配置文件 GRUB_CMDLINE_LINUX ="rhgb quiet net.ifnames=0" 或:修改/boot/grub2/grub.cfg (2) 为grub2 生成其配置文件 grub2-mkconfig -o /etc/g…

    Linux干货 2016-09-11
  • 8月2日作业

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

    Linux干货 2016-08-05
  • Linux Basic–磁盘分区

    附件: 磁盘管理相关方法.pdf

    Linux干货 2016-11-21
  • HAProxy实现请求的80端口转发至后端的8000端口并实现动静分离

    一 实验目的 用HAProxy作为负载均衡器,实现把前端请求调度到后端,前端监听80端口,转发至后端的8000端口,并会对访问资源进行判断实现不同的访问内容转发至相对应的服务器。 二 实验拓扑 三 实验环境 IP 功能 192.168.20.108 HAProxy 192.168.237.129 Nginx 192.168.237.130 Nginx+PHP…

    Linux干货 2016-12-19