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

相关推荐

  • M22 使用非对称密钥实现ssh自动登陆

    一 实验目的 一般在用户使用ssh客户端登陆ssh服务器时需要使用用户名和密码,本实验使用非对称加密的方式实现了无密码登陆ssh服务器。 二 实验流程  、 1 在客户端生成非对称密钥对 2 将非对称密钥中的公钥发送给ssh服务器端相应的帐号 3 当客户端通过ssh协议与服务器端发起连接时,客户端将私钥加密过的签名发送给服务器端,服务器端使用客户端…

    2017-04-13
  • ps查看进程

    ps命令 ps [OPTION]支持三种选项UNIX选项 如-A -eBSD选项 如aGNU选项 如–help选项:默认显示当前终端中的进程a 选项包括所有终端中的进程x 选项包括不连接终端的进程u 选项显示进程所有者的信息f 选项显示进程树,相当于 –forestk|–sort 属性 对属性排序,属性前加- 表示倒序o …

    2017-12-19
  • date用法心得

    Linux时间格式极大程度的遵循了人类习惯,以下为部分常见时间。
    date命令本身提供了日期的加减运算,shell编程时灵活运用

    2017-11-09
  • CentOS6.7上编译安装MariaDB

    CentOS6.7上编译安装MariaDB

    系统运维 2016-06-03
  • 第一周作业

    作业

    Linux干货 2018-03-20
  • 查找、压缩 随记

     查找模块 1. locate : 非实时查找(数据库查找)     实时查找: find locate 查询是建立在系统上预建的文件索引数据库 /var/lib/mlocate/mlocate.db 索引的构建是在系统较为空闲时自动进行(周期性任务); 管理员手动更新数据库(updatedb) 索引构建过程需要遍历整个根文件系…

    Linux干货 2016-08-15