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

相关推荐

  • Linux的哲学思想

    Linux的哲学思想 一切皆文件 在linux中所有的一切,都是可以通过ls进行查询的到的,甚至可以说ll查看详细信息时表现形式为文件,所有的设备,所有的文件不论后缀,只是一个单纯文件通过vim可以编辑一切 单一目的的小程序,组合小程序完成复杂任务 在linux中,每一个命令都是对应一个功能,通过不同的参数来完成不同的要求,通过繁多的小的命令来完成大型的要求…

    Linux干货 2016-10-30
  • 源码编译安装Apache

    编译安装Apache 系统环境:centos 7.2 前提: 提供开发工具及开发环境 开发工具:make, gcc等 开发环境:开发库,头文件 glibc:标准库 方式: 通过“包组”提供开发组件 centos 6 [root@centos6 ~]# yum groupinstall "Develo…

    Linux干货 2016-08-24
  • 7.28_Linux_ext数据结构inode的原理浅析、软硬链接的区别

    inode表结构浅析 下图以ext文件系统为参考,以4k块大小分区,简单描述一下ext文件系统的数据结构原理,如果有任何错误,烦请各位指出 inode 索引节点 硬盘上的每个磁道被等分为若干个弧段,这些弧段便是磁盘的扇区。硬盘的读写以扇区为基本单位。 扇区的大小,是2的N次方倍。分区的大小可以有多样,1k、2k、4k…以4k块大小来说明。4k块大…

    Linux干货 2016-08-03
  • 程序包管理rpm

    Linux程序包管理      API:Application Program Interface      ABI:Application Binary Interface         Unix…

    Linux干货 2016-08-23
  • Linux用户和组管理类命令以及文本处理工具的各种实例

    列出当前系统上所有已经登录的用户的用户名,注意:同一个用户登录多次,则只显示一次即可。 取出最后登录到当前系统的用户的相关信息。 取出当前系统上被用户当作其默认shell的最多的那个shell。 将/etc/passwd中的第三个字段数值最大的后10个用户的信息全部改为大写后保存至/tmp/maxusers.txt文件中。 取出当前主机的IP地址,提示:对i…

    2018-03-13
  • GRUB管理

    对于运维人员来说,想要熟练掌握linux,那么久要对linux的启动流程有一个详细的了解,而今天我们就一起来学习一下linux启动中最重要的一个阶段——GRUB引导阶段。 Linux启动流程 grup: GRand Unified Bootloader  由上图可知,grub属于系统启动过程中一个必须的阶段。而这个阶段又分为了三个小的阶段,分别是s…

    2017-09-02