用户权限以及组权限作业

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
下一篇 2016-08-08

相关推荐

  • 有关脚本的一些使用及其注意事项

    1,shell 脚本 格式要求:首行shebang机制                  #!/bin/bash       &n…

    2017-08-05
  • 难搞的grep、find练习题

    马哥教育网络班21期-第五周博客作业 1、显示/boot/grub/grub.conf中以至少一个空白字符开头的行; [root@caicai ~]# grep –color "^[[:space:]]\+" /boot/grub/grub.conf    …

    Linux干货 2016-07-26
  • 搭建CA服务器为Client签发证书

    搭建CA服务器为Client签发证书   此次实验步骤如下: 一、搭建CA服务器 1)  在/etc/pki/CA下创建index.txt文件,此文件是为Client签发证书的索引文件; 2)  在/etc/pki/CA下创建serial文件,此文件记录为Client签发证书的编号; 3)  生成CA服务器私钥; 4)…

    2017-05-21
  • Linux基础学习总结(六)

    一、创建一个10G分区,并格式为ext4文件系统; 1、要求其block大小为2048, 预留空间百分比为2, 卷标为MYDATA, 默认挂载属性包含acl; [root@blog ~]# fdisk /dev/sdfCommand (m for help): nCommand action e extended p primary partition (1…

    2016-11-06
  • shell位置变量解析

    什么是位置变量 在脚本代码中调用通过命令行传递给脚本的参数。 有哪些位置变量 $1,$2,…: 对应第1、第2等参数,shift [n]换位置 $0:命令本身 $*:传递给脚本的所有参数,全部参数合为一个字符串 $@:传递给脚本的所有参数,每个参数为独立字符串$#:传递给脚本的参数的个数    &nbsp…

    Linux干货 2016-08-15
  • Linux中软链接和硬链接的区别

    Linux中软链接和硬链接的区别 链接文件:   Linux中包括两种链接:硬链接(Hard Link)和软链接(Soft Link),软链接又称为符号链接(Symbolic link)。 Inode 文件除了纯数据本身之外,还必须包含有对这些纯数据的管理信息 文件名; 访问权限; 文件的属主以; 该文件的数据所对应的磁盘数据块; 文件的时间戳; …

    Linux干货 2016-10-20