用户权限以及组权限作业

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

相关推荐

  • 系统启动流程与GRUB管理

    系统启动流程: POST–>读取BootSequence(BIOS),决定引导次序–>读取引导设备的Bootloader(MBR grubstage1–>stage1.5/boot/filkeststem)–>boot–>/boot/grub.conf–>磁盘分区读取 kernel(ramd…

    Linux干货 2016-09-13
  • Keepalive高可用Nginx服务测试

    环境   系统版本:CentOS 7.2  节点1地址:10.1.8.81  节点2地址:10.1.8.83  虚拟IP地址:10.1.8.248 安装软件     yum -y install nginx     yum -y …

    Linux干货 2017-02-16
  • linux发行版说明和哲学思想,以及常用命令说明

    Linux发行版主要流行的版本有3种:debian,slackware,red 其说明和特点如下图。 Linux哲学思想: 1、一切皆文件;所有的一切都变成了文件!不光是软件方面的比如传统文件、目录、字符设备、还包括硬件或者接口。如鼠标/mouse、打印机/lp、还有接口比如/usb. 2、单一目的的小程序;一个程序只负责干一件事,而且要把这个任务做好。 3…

    Linux干货 2016-10-30
  • 2016 10 19 第5天作业

    20161019第5天作业 软链接和硬链接的区别 硬链接 ①硬链接文件不能跨分区创建 ②一个硬链接文件的删除不影响其他链接的访问 ③链接文件指向的源文件被删除后,链接文件还能正常访问源文件的数据 ④硬链接的文件类型是 –  普通文件 ⑤硬链接和源文件的属性(大小,权限,时间戳,Inode号)相同 ⑥硬链接不能对目录创建 ⑦创建硬链接会增…

    Linux干货 2016-10-20
  • Linux基于PXE实现系统全自动无人值守安装

    前言 在生产环境中,我们时常会需要在多台客户端主机或服务器安装操作系统,如果每一台都去手动安装,费时费力,显然是不现实的。那么,如何高效的完成此类工作呢?文将讲解如何实现Linux系统的全自动无人值守安装。 提供PXE服务所需安装包 dhcp:动态主机配置协议,给客户端提供ip地址 tftp-server:tftp服务器端,提供系统安装所需文件 xinetd…

    Linux干货 2015-04-01
  • HA Cluster-主备模型(项目实战)

    主机环境:主机A和主机B使用的是CentOS7.2的系统:    主机A IP地址为:192.168.1.103     主机B IP地址为:192.168.1.106     向外界提供的服务的地址为:192.168.1.100配置过程:…

    Linux干货 2016-11-01