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)
上一篇 2016-08-05 16:20
下一篇 2016-08-05 21:42

相关推荐

  • web服务介绍二)

    apache指令说明:http://httpd.apache.org/docs/2.2/mod/directives.html Listen 172.18.100.67:8081  监听某个指定地址和端口启动前检查一下语法:    httpd -t 如果要监听多个端口,要多行写    Listen 80&nb…

    Linux干货 2017-04-20
  • 配置使用基于mysql存储rsyslog日志信息

    配置使用基于mysql存储rsyslog日志信息   日志对于我们来说,肯定不会陌生。每个系统应用,只要有人访问,每时每刻都会产生大量的日志,用来记录服务器应用的运行信息。以便于我们在服务有异常时进行查看,或是从日志记录中提取出应用系统的运行信息。某些电商Web网站甚至会利用日志记录去对用户的购买行为作分析,以便更好的服务于客户。 &nb…

    Linux干货 2016-09-05
  • Linux基础系列(用户,组管理)

       Linux是一个多用户操作系统多任务的分时操作系统,平时的日常使用离不开用户登录以及用户组的管理,熟练管理用户和用户组,会提升我们的工作效率。   Linux用户管理:   Linux包括系统管理员,普通用户。普通用户又分为系统用户和登录用户。系统用户一般不会登陆系统,其shell类型一般为/etc/nologi…

    Linux干货 2016-08-04
  • 基于heartbeat v1+ldirectord实现LVS集群高可用

    前言 高可用集群,High Availability Cluster,简称HA Cluster,是指以减少服务中断时间为目的的服务器集群技术。通过上文可以看出,LVS集群本身并不能实现高可用,比如Director Server不能检测Real Server的健康度,一旦其中一台或全部Real Server宕机,Director Server还会继续转发请求,…

    Linux干货 2015-06-08
  • Linux-文件基本权限及特殊权限详解

    Linux文件基本权限及特殊权限详解 背景 Linux文件基本权限和特殊权限对于初学者很少烦恼,各种无法理解,所以在学到这一节时,将自己学到的以及自己的理解写出来以检查自己对这个部分的掌握情况。 什么是权限 在Linux里一切皆文件,所谓的权限就是用户对文件(目录也是以个文件)的操作范围,对文件的操作包括读、写和执行,用户对文件有不同的权限就能做相应的操作。…

    Linux干货 2017-07-22
  • 8.3_Linux文件系统权限和特殊权限浅析

    什么是Linux文件系统权限? 在Linux中的每一个文件或目录都包含有访问权限,这些访问权限决定了谁能访问和如何访问这些文件和目录。 Linux文件系统权限的分类 Linux中的权限分为:read(读)、write(写)、execut(执行)三种权限 文件和目录表示的权限也各有不同 权限对于文件的意义: r: 可使用文件查看类工具获取其内容 w: 可修改内…

    Linux干货 2016-08-05