用户权限以及组权限作业

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

相关推荐

  • samba的部署及应用

    samba: 启动服务:nmb.server;smb.server 会通过文件系统的方式输出给客户端 smb:Service Message Block;服务信息块 cifs:Common Internet File System,通用互联网文件系统 samba:Andrew Tridgell;热情奔放的桑巴…

    Linux干货 2016-10-19
  • 第四周练习与作业

    一、复制/etc/profile至/tmp/目录,用查找替换命令删除/tmp/profile文件中的行首的空白字符 复制文件至/tmp目录下: cp /etc/profile /tmp/ vim /tmp/profile 进入文件命令模式下,使用正则表达式  ;%s/^[[:blank:]]\+//g 二、复制/etc/rc.d/init.d/fu…

    2017-08-05
  • Linux进程管理命令和性能监控工具的应用

    概述 监控系统的各方面的性能,保障各类服务的有序运行,是运维工作的重要组成部分,本篇就介绍了一些常用的系统监控命令和相关参数的说明 具体包含一下几个部分 1.进程管理基础 2.进程管理工具(ps,top,htop,kill) 3.内存监控类工具(vmstat,pmap) 4.系统监控累工具(glances,dstat)…

    Linux干货 2016-09-26
  • awk详解

    —————————— 课外练习 只处理用户ID为奇数的行,并打印用户名和ID号 [root@localhost ~]# awk -F: '{if($3%2!=0) {print&n…

    Linux干货 2016-09-25
  • 基于centos7的http的应用

     练习:分别使用CentOS 7和CentOS 6实现以下任务         (1) 配置三个基于名称的虚拟主机;             (a) discuzX             …

    Linux干货 2016-10-12