8月2日作业

在/data/testdir里创建的新文件自动属于g1组,组g2的成员如:alice能对这些新文件有读写权限,组g3的成员如:tom只能对新文件有读权限,其它用户(不属于g1,g2,g3)不能访问这个文件夹。


[root@localhost ~]# groupadd g1

[root@localhost ~]# groupadd g2

[root@localhost ~]# groupadd g3

[root@localhost ~]# mkdir -p /data/testdir

[root@localhost ~]# chown -R :g1 /data/testdir

[root@localhost ~]# ll -d /data/testdir

drwxr-xr-x. 2 root g1 6 8月   2 19:48 /data/testdir

[root@localhost ~]# chmod 770 /data/testdir

[root@localhost ~]# ll -d /data/testdir

drwxrwx—. 2 root g1 6 8月   2 19:48 /data/testdir

[root@localhost ~]# useradd -G g2 alice

[root@localhost ~]# useradd -G g3 tom

[root@localhost ~]# setfacl -m g:g2:rw /data/testdir

[root@localhost ~]# setfacl -m g:g3:r /data/testdir

[root@localhost ~]# getfacl /data/testdir

getfacl: Removing leading '/' from absolute path names

# file: data/testdir

# owner: root

# group: g1

user::rwx

group::rwx

group:g2:rw-

group:g3:r–

mask::rwx

other::—

[root@localhost ~]# ll -d /data/testdir/

drwxrwx—+ 2 root g1 6 8月   2 19:48 /data/testdir/


创建组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 ~]# gpasswd sales

正在修改 sales 组的密码

新密码:

请重新输入新密码:

[root@localhost ~]# useradd -G sales user2

[root@localhost ~]# gpasswd -A user2 sales

[root@localhost ~]# useradd -G sales user1

[root@localhost ~]# useradd -G sales user3

[root@localhost ~]# usermod -g sales user1

[root@localhost ~]# su – user1

[user1@localhost ~]$ touch 1.txt

[user1@localhost ~]$ ll 1.txt 

-rw-r–r–. 1 user1 sales 0 8月   2 20:09 1.txt

[user1@localhost ~]$ exit

登出

[root@localhost ~]# su – user2

[user2@localhost ~]$ gpasswd -d user3 sales

正在将用户“user3”从“sales”组中删除

[user2@localhost ~]$ exit

登出

[root@localhost ~]# userdel -r user1

userdel:组“user1”没有移除,因为它不是用户 user1 的主组

[root@localhost ~]# userdel -r user2

[root@localhost ~]# groupdel sales

原创文章,作者:zebra930,如若转载,请注明出处:http://www.178linux.com/27631

(0)
zebra930zebra930
上一篇 2016-08-05
下一篇 2016-08-05

相关推荐

  • 8.8作业

    4、如何设置tab缩进为4个字符?    set tabstop=4     5、复制/etc/rc.d/init.d/functions文件至/tmp目录;替换/tmp/functions文件中的/etc/sysconfig/init为/var/log; cp /etc/rc.d/init.d/functi…

    Linux干货 2016-08-11
  • 推荐-Nginx Rewrite的应用-根据访问平台做简单跳转

    Nginx Rewrite的应用-根据访问平台做简单跳转 Nginx Rewrite的应用-根据访问平台做简单跳转 Rewrite模块简介 Rewrite的配置 使用不同平台进行测试 配置参数详解 Rewrite模块简介    Rewrite最主要的作用就是对URL进行重写,即重定向。举个简单的例子,我们用电脑打开淘宝显示出的页面与手机打开显示出的页面,或者…

    Linux干货 2016-03-27
  • N25-第五周作业

    第五周 1、显示/boot/grub/grub.conf中以至少一个空白字符开头的行; [root@zf ~]# grep -E "^[[:space:]]+[[:alnum:]]+" /boot/grub/grub.conf     &n…

    Linux干货 2016-12-26
  • 用户和组管理类命令详解

    用户和组管理类命令详解 组管理 groupadd 功能描述:创建一个新组 命令格式: groupadd [选项] GROUP 选项: -g GID 表示指定GID,默认情况下使用的是最小的未使用过的GID -r 表示创建一个系统组 groupmod 功能描述:修改组属性 命令格式:groupmod [选项] GROUP 选项: -g GID 表示修改GID …

    Linux干货 2017-07-16
  • 系统服务之LVS 集群

    Linux集群(Cluster) 一.概论 1.定义     Cluster:计算机集合;     linux集群,多台Linux主机为解决某个特定问题组合起来形成的单个系统;     由于现代化业务上线的需求, 单服务器已经不能…

    Linux干货 2016-10-28
  • LVM 2 介绍以及怎么使用?

    一、 LVM是什么? LVM利用Linux内核的device-mapper来实现存储系统的虚拟化(系统分区独立于底层硬件)。 通过LVM,你可以实现存储空间的抽象化并在上面建立虚拟分区(virtual partitions),可以更简便地扩大和缩小分区,可以增删分区时无需担心某个硬盘上没有足够的连续空间, without getting caught up …

    Linux干货 2017-01-06