8月2日作业

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

[root@localhost testdir]# groupadd g1
[root@localhost testdir]# groupadd g2
[root@localhost testdir]# groupadd g3
[root@localhost testdir]# mkdir -p /date/testdir
[root@localhost testdir]# chmod 770 /date/testdir
[root@localhost testdir]# chown :g1 /date/testdir
[root@localhost testdir]# useradd -G g2 alice
[root@localhost testdir]# useradd -G g3 tom
[root@localhost testdir]# setfacl -Rm g:g2:rwx /date/testdir/
[root@localhost testdir]# setfacl -Rm g:g3:rx /date/testdir/
[root@localhost testdir]# getfacl /date/testdir/
getfacl: Removing leading '/' from absolute path names
# file: date/testdir/
# owner: root
# group: g1
user::rwx
group::rwx
group:g2:rwx     //题目要求读写,没有x权限也不行
group:g3:r-x     //题目要求读权限,如果没有x权限是不能读的
mask::rwx
other::---

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 ~]# gpasswd sales
Changing the password for group sales
New Password: 
Re-enter new password: 
[root@localhost ~]# useradd -G sales user1
[root@localhost ~]# useradd -G sales user2
[root@localhost ~]# useradd -G sales user3
[root@localhost ~]# gpasswd -A user2 sales
[root@localhost ~]# usermod -g sales user1
[root@localhost ~]# su - user1
[user1@localhost ~]$ touch user1.txt
[user1@localhost ~]$ ls -l user1.txt 
-rw-r--r-- 1 user1 sales 0 Jul 25 12:28 user1.txt   //查看user1创建文件默认属组为sales
[user1@localhost ~]$ exit
logout
[root@localhost ~]# su user2
[user2@localhost root]$ 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

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

(0)
LiiLii
上一篇 2016-08-05 16:20
下一篇 2016-08-05 21:42

相关推荐

  • 马哥教育网络20期+第8周练习博客

    1、请描述网桥、集线器、二层交换机、三层交换机、路由器的功能、使用场景与区别。 网桥:链接层设备,基于MAC地址过滤。 集线器:物理层设备,基本都属于半双工模式。集线器与网桥在现在的局域网中基本都不用了。 二层交换机:基本MAC转发数据,功能齐全的可支持VLAN等功能。常见的有100/1000M、16口/24口/48口。 三层交换机:功能齐全的交换机,具备都…

    Linux干货 2016-08-01
  • Centos6.5上搭建openvpn

    一、openvpn原理 二、安装openvpn 三、制作相关证书     3.1 制作CA证书     3.2 制作Server端证书     3.3 制作Client端证书 四、配置Server端 五、配置C…

    Linux干货 2016-04-28
  • 第八周-Shell脚本编程

    1、写一个脚本,使用ping命令探测172.16.250.1-172.16.250.254之间的所有主机的在线状态; 在线的主机使用绿色显示; 不在线的主使用红色显示; #!/bin/bash for i in {1..254}; do { ip=172.16.250.$i if ping -c 1 -w 1 $ip &> /dev/null …

    Linux干货 2017-08-23
  • Linux硬链接和软链接

    标签:    inode    软链接    硬链接 一、ionde及inode编号   在计算机中,信息一般以扇区(sectors)的形式存储在硬盘上,而每个扇区包括512个字节的数据和一些其他信息(即一个扇区包括两个主要部分:存储数据地点的标识符和存储数据的数据段)。操作系统…

    Linux干货 2016-10-20
  • Linux ssh安全远程登录

                   Linux ssh安全远程登录 本章内容:     构建SSH远程登录系统     SSH(secure shell)是标准的网络协议,主要用于实现字符界面的远程登录管理…

    Linux干货 2016-10-10
  • 计算机之路及初识linux

    写在前面:     很抱歉,上周的事儿,拖到这周,也是个半成品,加班就不多说了,每个人都很忙,总要自己找时间。本计划这个周末好好补补,无奈身不由己,刚刚回来。    还好昨夜先起了个初稿,总算是有些东西可以交代给自己,想到马哥说的,完成远比完善重要,虽然来不及完善,先发出来吧,有了框架,至少知道自己做过什么。尽快排版吧…

    Linux干货 2016-12-05