用户权限以及组权限作业

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

[root@localhost testdir]# mkdir -p /data/testdir
[root@localhost testdir]# groupadd g1
[root@localhost testdir]# groupadd g2
[root@localhost testdir]# groupadd g3
[root@localhost testdir]# chgrp g1 /data/testdir
[root@localhost testdir]# useradd -G g2 alice
[root@localhost testdir]# useradd -G g3 tom
[root@localhost testdir]# chmod g+s /data/testdir
[root@localhost testdir]# setfacl -Rm d:g:g2:rwx /data/testdir
[root@localhost testdir]# setfacl -Rm d:g:g3:r /data/testdir
[root@localhost testdir]# getfacl /data/testdir

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 ~]# echo centos > gpasswd --stdin sales
[root@localhost ~]# gpasswd -A user2 sales
[root@localhost ~]# usermod -g sales user1
[root@localhost ~]# gpasswd -a user1 sales
[root@localhost ~]# gpasswd -a user2 sales
[root@localhost ~]# gpasswd -a user3 sales
[root@localhost ~]# su - user1
Last login: Sat Aug  6 15:28:56 CST 2016 on pts/0
[user1@localhost ~]$ touch a.txt
[user1@localhost ~]$ ll !$
ll a.txt
-rw-r--r--. 1 user1 sales 0 Aug  6 15:38 a.txt
[user1@localhost ~]$ exit
logout
[root@localhost ~]# su - user2
Last login: Fri Aug  5 21:37:49 CST 2016 on pts/0
[user2@localhost ~]$ 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
[root@localhost ~]# tail -3 /etc/passwd 
wangcai:x:1006:1006::/home/wangcai:/bin/bash
gentoo:x:1007:1007:Gentoo Distribution:/home/gentoo:/bin/csh
user3:x:1010:1010::/home/user3:/bin/bash
[root@localhost ~]# tail -3 /etc/group
g3:x:3003:
user1:x:1008:
user3:x:1010:

原创文章,作者:皱 多利亚,如若转载,请注明出处:http://www.178linux.com/29861

(0)
皱 多利亚皱 多利亚
上一篇 2016-08-08 16:14
下一篇 2016-08-08 16:15

相关推荐

  • 马哥教育网络班21期+第四周博客作业

    1、复制/etc/skel目录为/home/tuser1,要求/home/tuser1及其内部文件的属组和其它用户均没有任何访问权限。 2、编辑/etc/group文件,添加组hadoop。 3、手动编辑/etc/passwd文件新增一行,添加用户hadoop,其基本组ID为hadoop组的id号;其家目录为/home/hadoop。 4、复制/etc/sk…

    Linux干货 2016-07-07
  • yum函数介绍以及自建yum仓库

    一、前言     在之前介绍了yum的配置(详细请移步 http://www.178linux.com/archives/6445)。但是有没有发现一个问题,虽然我们已将仓库指向一个可用的仓库服务器,但是随着Linux的不断升级和改版,我们是否还需要不断的去修改仓库的配置文件,如果只有一台还好,那如果我们有多…

    Linux干货 2015-07-24
  • 软链接与硬链接的区别

      这两牵扯到链接,那么先介绍以下链接。   在文件系统中,有一种可以把不同的文件相连接到一起的机制,这个机制叫做链接。通俗的话来说就是打开两个不同的文件夹,其实进去的是同一个。它可以把一个文件用不同的名字和路径来表示出来。系统通过inode(索引节点,文件唯一标识)来识别是否为同一个文件,无论系统上有有多少个链接,在磁盘上只有一个唯一的…

    2017-05-25
  • LVS的详细应用

    LVS是Linux Virtual Server的简写, 意思是Linux虚拟服务器, 是一个虚拟的服务器集群系统. LVS的宗旨:    1. 使用集群技术和Linux操作系统实现一个高性能, 高可用的服务器;    2. 很好的可伸缩性(Scalability);    3. 很好的可靠性(Re…

    Linux干货 2016-12-05
  • 网络班N22期第四周博客作业

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

    Linux干货 2016-09-05
  • shell脚本编程

    一、编程基础: shell脚本是包含一些命令或声明,并符合一定格式的文本文件 shell脚本的用途有: 自动化常用命令 执行系统管理和故障排除 创建简单的应用程序 处理文本或文件 1)     第一步:使用文本编辑器来创建文本文件 script.sh 并编写内容 格式要求:首行shebang &nb…

    Linux干货 2016-08-15