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

相关推荐

  • systemd管理

    centos7:systemdSystemd :系统启动和服务器守护进程管理器,负责在系统启动或运行时,          激活系统资源,服务器进程和其它进程Systemd 新特性:        系统引导时实现服务并行启动      &n…

    Linux干货 2017-04-10
  • 第二周

    第二周 1. Linux上的文件管理类命令都有哪些,其常用的使用方法及其相关示例演示。 cp 复制文件和目录语法格式:cp [OPTION]… [-T] SOURCE DESTcp [OPTION]… SOURCE… DIRECTORYcp [OPTION]… -t DIRECTORY SOURCE&#8230…

    Linux干货 2017-07-21
  • awk用法一

      gawk程序是Unix中的原始awk程序的GNU版本,它提供了一种编程语言而不只是编辑器命令。在CentOS中awk命令实际上是gawk程序的链接文件名。   基本语法:     awk [options] ‘program’ flie1 file2 ……

    Linux干货 2015-12-24
  • Linux软件包管理

      在我们的运维工作,总是避免不了安装某些软件,或者编译安装某些软件,我们知道操作系统当中的程序都是有程序员通过开发工具开发的来,程序员直接编写的纯文本的文档我们称之为源代码,但我们的计算机只能识别二进制程序,那么必须要将源代码变成计算机能识别的二进制程序,这里需要通过编译器来进行编译,将源码转换成二进制程序,再通过安装即可。 还有一类程序就是二进…

    Linux干货 2016-08-24
  • SElinux

    selinux  配置文件 修改   就要重启 targeted:用来保护常见的网路服务,仅有限进程受到selinux控制,只监控容易被入侵的进程。 targeted  慢慢完善的法律 系统默认使用   targeted     CENTOS6 CENTOS7 ZAI &nbsp…

    Linux干货 2016-09-14
  • 学习札记:用户管理,权限管理和ACL欢乐”斗地主”

    补充:touch /etc/nologin 启动系统维护功能,其他用户不能登陆,除了管理员,可以自定义内容,在普通用户登陆的时候可以看到相关维护提示,解除维护模式的话,必须要删除该文件,另外可以创建/run/nologin达到相同的效果(仅限于CentOS 7), 用户属性修改 usermod [OPTION] login -u UID: 新UID -g G…

    Linux干货 2016-08-04