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

相关推荐

  • 马哥教育网络班21期+第一周课程练习

    1、描述计算机的组成及其功能。 计算机由五大组件组成包括:计算器,控制器,存储,输入设备,输出设备。 运算器:做运算,且只能做二进制运算,包括算术运算和逻辑运算,如加减乘除,移位,取模。运算器的核心是加法器。 控制器:控制整个计算机部件之间协调。比如做计算,运算器先从存储器取数,运算器作运算,再回存存储器。这整个过程都由控制器做协调。  &nbsp…

    Linux干货 2016-07-12
  • linux系统故障排除总结

    常见的系统故障 1.确定文体的故障特征 2.重现故障 3.使用工具收集进一步信息,确定根源在何处 4.排除不可能的原因 5.定位故障:             从简单的问题入手      &…

    Linux干货 2016-09-15
  • etc的常见问答

    1、复制/etc/skel目录为/home/tuser1,要求/home/tuser1及其内部文件的属组和其它用户均没有任何访问权限。 [root@localhost tuser1]# cp -r /etc/skel/ /home/tuser1 [root@localhost tuser1]# chmod -R go= /home/tuser1/ [root…

    2017-12-26
  • 胡说八道计算机网络之什么是网络(一)?

    胡说八道计算机网络之什么是网络(一) 什么是网络? 网络通信的实现:tcp/ip协议 使用Wireshark抓包分析tcp/ip协议栈 什么是网络?      所谓网络,就是通过一定的形式连接起来的物体,物体与物体之间可以实现通信。     比如这样的,就称为计算机网络。它可以实现计算机之…

    Linux干货 2017-05-01
  • lvs–各类型的原理及实现—(原理篇)

    前言:    LVS即是linux虚拟服务器,是一个虚拟的服务器集群系统,目的是使用集群技术和linux操作系统实现一个高性能、高可用的服务器。采用IP负载均衡技术和基于内容请求分发技术,将请求负载均衡地转移到不同的服务器上执行,从而将一组服务器构成一个高性能、高可用的虚拟服务器。此篇的内容只包含两种较为常用的LVS技术,分别是LVS-N…

    Linux干货 2016-10-27
  • Linux发展史

    摘要:Linux无处不在的存在于我们的周围,家庭、公司、学校等等。现在的Linux已经从最初示很少的一段代码,发展成全世界应用范围最广的操作系统。本文将为大家展现Linux的发展史。 一、Linux的是什么       Linux是一套可以免费使用和自由传播的类Unix操作系统操作系统,是一个基于POSIX和UNIX的多用户、多…

    Linux干货 2016-10-18