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
下一篇 2016-08-05

相关推荐

  • 加密和解密技术基础(01) ~ 105分钟

    加密和解密技术基础(01) ~ 105分钟 讲课思路: 互联网通信机制 –> 网络协议模式(osi,tcp/ip模型) –> 数据通信安全  à 数据加密 –> 加密算法 –> OpenSSL是什么 à SSL通信原理 –> CA –> OpenSSL命令用法 à CA 自签及签证演示 1.1 &nbs…

    Linux干货 2016-09-19
  • 计算机构成与Linux基础知识之一

    简述计算机构成,Linux如何诞生及主流发行版;简单命令介绍;如何获取帮助及Linux目录命名及功用简介绍。

    2018-02-26
  • yum前端工具与源码编译安装

    概述:本章内容重要讲解yum(rpm前端工具)和rpm源码编译安装,前者可以有效的解决软件安装过程中存在的依赖关系,从而提升我们使用系统的效率;后者是我们进阶Linux系统,了解程序包安装的过程本质 1、YUM: Yellowdog Update Modifier   Yum(全称为 Yellow dog Updater, Modified)是一个…

    Linux干货 2016-08-29
  • 运维必备的”武器库”

    作者总结的干货,拿来分享给大家,满满的全是干货 Blog:http://www.simlinux.comWeibo:http://weibo.com/geekwolf Bootstrapping: Kickstart、Cobbler、rpmbuild/xen、kvm、lxc、Openstack、 Cloudstack、Opennebula、Eucalyplu…

    Linux干货 2015-03-13
  • 数据库

    数据库系统理论概述(一) –本文主要讲述: – 1.数据库和数据库管理系统 – 2.使用传统的文件系统对大量数据管理存在的问题 – 3.常见的数据库系统模型 – 4.数据库视图 – 5.数…

    Linux干货 2016-10-30