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 16:13
下一篇 2016-08-05 16:15

相关推荐

  • 为什么系统可执行文件多用相对路径创建链接

    为什么系统可执行文件多用相对路径创建链接 使用链接有什么好处 作为一个linux初学者,我们首先要知道,在linux中使用链接的好处是什么。总结下来一共有几个: 使用链接可以使我们在访问文件时省去一大笔敲文件路径的时间。对于我们运维工程师来说,我们经常要查看某个文件或者访问某个目录,再进行该项工作时,往往需要敲很多路径才能找到我们想访问的文件,创建链接可以让…

    Linux干货 2017-07-23
  • Linux的发展史

       在早期电气化发展时代1946年诞生了计算机事物,早期的计算机体积巨大,只能适用于一个人操作,而且运行速度慢。但已经形成计算机的架构体系,为了尽可能的榨干计算机资源在计算机发展的二阶段,于是有当时著名实验室BELL ,GE,MIT共同研发了一款叫MULTCS操作系统,这也是最早的操作系统。   1946年一个没有完成的梦想,…

    Linux干货 2016-10-13
  • 磁盘分区,文件系统的创建、修改和检测

        写博客,对我来说不仅是学习的过程,也是一个心理历练的过程,多说无益,开始吧!!!     博客是马哥视频里的博客作业:文件系统的创建、修改和检测。我就从磁盘管理开始把      环境:     创建的centos6.5虚拟机 &nb…

    Linux干货 2016-06-26
  • Nginx相关配置及其应用

    LB Cluster: 传输层:lvs、nginx、haproxy 应用层:nginx(http, https, smtp, pop, imap), haproxy(http), httpd(http/https), ats, perlbal, pound, … nginx load balancer: tcp/udp   nginx …

    Linux干货 2016-11-11
  • grep,egrp,fgrep 命令与正则表达式

    一 简介     grep (global search regular expression(RE) and print out the line,全面搜索正则表达式并把行打印出来)是一种强大的文本搜索工具,它能使用正则表达式搜索文本,并把匹配的行打印出来。 Unix的grep家族包括grep、egrep和fgrep…

    Linux干货 2016-01-19
  • TCP连接的状态转移

    TCP是一个面向连接的传输层协议,因此不论哪一方需要传输数据,都需要在双方之间建立一条传输连接。 用TCP的三次握手与四次挥手来解释TCP的各个状态之间的会比较清晰。 一、TCP的三次握手: a)         单方主动发起连接: 1、  服务器端应用层的应用程序创建…

    2017-03-19