用户权限以及组权限作业

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

相关推荐

  • 马哥教育网络班22期+第四周课程练习

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

    Linux干货 2016-09-06
  • find命令用法及示例

    文件查找 locate,find可是实现在文件系统上查找符合条件的文件 实现工具:locate,find locate有几下几个特性 1、依赖于事先构建好的索引库; 2、系统自动实现;(周期性任务) 3、手动更新数据库(updatedb) /var/lib/mlocate/mlocate.db 工作特性: 查找速度快; 模糊查找; 非实时查找 lo…

    Linux干货 2016-08-18
  • 字符切割和用户管理

    1、列出当前系统上所有已经登录的用户的用户名,同一个用户登录多次,则只显示一次 who |cut -d’ ‘ -f1 |sort -u2、取出最后登录到当前系统的用户的相关信息。 last |head -1|cut -d’ ‘ -f1 3、取出当前系统上被用户当作其默认shell的最多的那个shell。 cut…

    2017-12-17
  • 网络路由以及配置

               路由表的构成    目标网络的网络ID   Netmask 接口:到达目标网络的路由器出口  网关gateway: 1.如果目标网络和路由器直连,网关IP=接口的IP  2.如果目标网络和路由器非直连,下一个路由器临近…

    Linux干货 2017-07-02
  • 马哥教育网络21期+第八周练习博客

    马哥教育网络21期+第八周练习博客 # 1、请描述网桥、集线器、二层交换机、三层交换机、路由器的功能、使用场景与区别。 集线器:工作于ISO模型的物理层,防止由于距离远,信号衰减; 网桥:用来连接不同网段,隔离冲突域; 二层交换机:二层交换机一般做为了三层交换机以下,利用设备mac地址进行通信,可以划分vlan,隔离广播域; 三层交换机:用于核心数据转发,不…

    Linux干货 2016-09-05
  • RAID

    RAID:       Redunant ARRAYS OF Inexpensive Disks       廉价磁盘阵列 Independent        Berkeley: A case for Redundent Arrays of Inexpens…

    Linux干货 2016-12-23