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

相关推荐

  • 优云云监控:先定一个运维小目标,比方监控它10000台主机

    “想做世界最好是对的,但是最好先定一个能达到的小目标,比方说我先挣它一个亿。”,王首富云淡风轻地给各行各业提供了一个很好的Roadmap,包括我们运维。的确,如今数据中心的规模增长速度也已像一匹脱缰的野马,各地都频频建设起超大型数据中心。按工信部的定义,超大型是指规模大于等于一万个标准机架的数据中心,考虑到虚拟化技术的使用,实际上需要运维的主机规模很容易超过…

    系统运维 2016-12-05
  • 程序包管理yum

    YUM: YellowdogUpdate Modifier,rpm的前端程序,用来解决软件包相关依赖性,可以在多个库之间定位软件包 存储了众多rpm包,以及包的相关的元数据文件(放置于特定目录下:repodata) 文件服务器:     ftp://     http:// &n…

    Linux干货 2016-08-23
  • shell 脚本中数组的总结

    描述:   变量是存储单个元素的内存空间,而数组是多个变量的集合,是一个连续的空间;但整个数组只能有 的名字。   数组内的数据都有指定的索引,从而找到数组内所指定的数据。索引的编号是从0开始的,依次递增(0,1,2,3,…),这种方式叫数值索引。格式为:数组名[索引];${ARRAY_NAME[INDEX]}。索引也支持自定…

    Linux干货 2016-08-29
  • 第4周作业

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

    Linux干货 2016-12-25
  • 磁盘运作方式及分区,挂载等操作

    磁盘运作方式及分区,挂载等操作 磁盘是我们存储数据的空间,而为了方便我们对数据的管理,我们需要对磁盘进行分区。而在我们创建过分区之后 ,我们为了能 够访问磁盘 ,需要对磁盘进行挂载 。文件系统通过为每个文件在分区上分配文件块的方式把数据存储在硬盘上。所以,就是使用文件系统在 硬盘分区上对数据块的各种信息的操作。这样就需要我们了解磁盘的运作方式,学会磁盘的分区…

    Linux干货 2016-08-29