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)
上一篇 2016-08-05 16:20
下一篇 2016-08-05 21:42

相关推荐

  • ansible之Playbook中tags使用

    示例:httpd.yml– hosts: websrvsremote_user: roottasks:– name: Install httpdyum: name=httpd state=present – name: Install configure filecopy: src=files/httpd.conf des…

    Linux干货 2018-01-14
  • N22-第五周博客作业

    1、显示当前系统上root、fedora或user1用户的默认shell; [root@bogon ~]# grep -E  "^(root|fedora|user1)" /etc/passwd  | cut -d: -f1,7r…

    Linux干货 2016-09-26
  • Linux的正则表达式grep,egrep

    Linux的正则表达式grep,egrep 一、概念 正则表达式是对字符串操作的一种逻辑公式,用事先定义好的一组特殊字符,组成一个“规则字符集合”,根据用户指定的文本模式对目标文件进行逐行搜索匹配,显示能被模式匹配到的结果。 给定一个正则表达式和另一个目标字符串,我们可以从给定的字符串中通过匹配模型,过滤字符串中不想要的的字符串,得到目标字符串,减少工作量。…

    Linux干货 2017-05-07
  • vim编辑器的使用

    vim          vim是一个类似于vi的文本编辑器,不过在vi的基础上增加了很多功能,在早起vim和Emacs编辑器打的很火热,在1999年被linuxwork文本编辑分类的优胜者,而vim屈居第二,但2000年vim赢得了salashdot beanie的最佳开放源代…

    系统运维 2016-08-09
  • Linux中的cut、sort、uniq以及用户(组)管理类指令应用示例

    Linux中的cut、sort、uniq指令 列出当前系统上所有已经登录的用户的用户名,注意:同一用户登录多次,只显示一次。 解决思路: 先使用who指令显示出所有已登录的用户。然后对who指令的输出进行切割得到想要的第一列内容,即只包含用户名。可以使用cut指令。最后对cut的结果进行排序并去重。可以使用sort指令。   借助管道符,可以方便的…

    Linux干货 2016-11-13
  • N25 the second week

    1.文件管理命令 1.1.cat concatenate files and print on the standard output # 正序打印文件 cat [OPTION]… [FILE]… # 常用参数 -n 编号显示每行 -E 显示每行的结束符 1.2.tac concatenat…

    Linux干货 2016-12-19