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

相关推荐

  • Linux文件管理命令详解–cp,mv,rm

    在Linux系统里平时需要对目录文件做一些管理操作,其中最基本的有cp,mv,rm等命令: cp命令:copy 复制   其中包含源文件,目标文件: copy分为单源复制和多源复制,详解如下:               单源复制:cp [option]…[-T] S…

    Linux干货 2016-11-06
  • 马哥linux第一周学习笔记

    计算机组成 Linux基本命令

    Linux干货 2017-12-17
  • Docker 实例

    1、Docker 安装 Nginx 方法一:通过 Dockerfile构建 创建Dockerfile 首先,创建目录nginx,用于存放后面的相关东西。 # mkdir -p nginx/www nginx/logs nginx/conf www目录将映射为nginx容器配置的虚拟目录 logs目录将映射为nginx容器的日志目录 conf目录里的配置文件将…

    2018-01-22
  • 无插件Vim编程技巧

    相信大家看过《简明Vim教程》也玩了《Vim大冒险》的游戏了,相信大家对Vim都有一个好的入门了。我在这里把我日常用Vim编程的一些技巧列出来给大家看看,希望对大家有用,另外,也是一个抛砖引玉的过程,也希望大家把你们的技巧跟贴一下,我会更新到这篇文章中。另外,这篇文章里的这些技巧全都是vim原生态的,不需要你安装什么插件。我的Vim的版本是7.2。 浏览代码…

    Linux干货 2016-08-15
  • N25_第四周作业(补)

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

    Linux干货 2017-01-02
  • 20160803作业-用户组和权限管理

    http://note.youdao.com/yws/public/redirect/share?id=46f06331b737c6d08a0e8c9c3d49ac9e&type=false

    Linux干货 2016-08-08