用户权限以及组权限作业

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

相关推荐

  • rsyslog记录日志于mysql

    rsyslog记录日志于mysql:     前提:准备好msql server或mariadb server;     (1) 安装rsyslog连接至mysql server的驱动模块;        &n…

    Linux干货 2016-12-05
  • Redis高可用架构(1)—Keepalive+VIP

    最近整理一下Redis高可用架构的文档,也准备分享出来,虽然这些架构也不是很复杂。Redis的高可用方案目前主要尝试过5种方式,其中2种方式已经在线上使用。 1)Redis Master-Slave + Keepalive + VIP。这是很经典的db架构,也可以用与mysql的主从切换。基本原理是:Keepalive通过脚本检测master的存活,然后通过…

    Linux干货 2016-04-13
  • corosync + pacemaker搭建高可用mysql

    一、实验图     二、环境准备  1)确保时间同步 [root@SQL1 ~]# crontab -e  */5 * * * * /usr/sbin/ntpdate 172.16.2.15 [root@SQL2 ~]#…

    Linux干货 2015-06-30
  • 第四周作业

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

    Linux干货 2016-12-27
  • 干货 | 20 行 Python 代码创建可视化地图

    当我开始建造Vincent时, 我的一个目的就是使得地图的建造尽可能合理化. 有一些很棒的python地图库-参见Basemap 和 Kartograph能让地图更有意思. 我强烈推荐这两个工具, 因为他们都很好用而且很强大. 我想有更简单一些的工具,能依靠Vega的力量并且允许简单的语法点到geoJSON文件,详细描述一个投影和大小/比列,最后输出地图. …

    2017-09-08
  • 初识Linux基础

    一:计算机的组成及其基本功能 计算机主要由五大基础部件组成:控制器,运算器,存储器,输入设备,输出设备。 1、控制器:计算机的核心组件,协调各程序的运行,对计算机的各项资源进行控制分配; 2、运算器:计算机实现算术运算以及逻辑运算的部件; 3、存储器:计算机用来存放数据和程序的基本部件,存储器由若干存储单元组成,每个存储单元都有一个             …

    Linux干货 2018-03-04