M20-1权限作业

1、当用户xiaoming对/testdir 目录无执行权限时,意味着无法做哪些操作?

[root@centos7 testdir]# ls -ld /testdir/
drwxr-xrw-. 3 root root 27 Aug  5 08:38 /testdir/
[root@centos7 testdir]# su xiaoming
[xiaoming@centos7 testdir]$ ls
ls: cannot open directory .: Permission denied
[xiaoming@centos7 testdir]$ cd dir
bash: cd: dir: Permission denied
[xiaoming@centos7 testdir]$ ll /testdir
ls: cannot access /testdir/file: Permission denied
ls: cannot access /testdir/dir: Permission denied
total 0
?????????? ? ? ? ?            ? dir
?????????? ? ? ? ?            ? file
[xiaoming@centos7 testdir]$ rm -rf dir
rm: cannot remove ‘dir’: Permission denied
[xiaoming@centos7 testdir]$ rm -f file
rm: cannot remove ‘file’: Permission denied
[xiaoming@centos7 testdir]$

从上诉实验可知,不能ls查看此目录和目录元数据,不能cd切换到此目录中,也不能删除目录中的文件文件夹
2、当用户xiaoming对/testdir 目录无读权限时,意味着无法做哪些操作?

[root@centos7 testdir]# chmod o=wx /testdir/
[root@centos7 testdir]# ls -ld /testdir/
drwxr-x-wx. 3 root root 27 Aug  5 08:38 /testdir/
[root@centos7 testdir]# su xiaoming
[xiaoming@centos7 testdir]$ ls
ls: cannot open directory .: Permission denied
[xiaoming@centos7 testdir]$ rm -rf file
[xiaoming@centos7 testdir]$ rm -rf dir
rm: cannot remove ‘dir/f1’: Permission denied
rm: cannot remove ‘dir/f2’: Permission denied
[xiaoming@centos7 testdir]$

从上诉实验可知,不能ls查看,但可以删除目录中文件,不能删除目录中的目录及文件

3、当用户wang对/testdir 目录无写权限时,该目录下的只读文件file1是否可修改和删除?

[root@centos7 testdir]# ls -ld /testdir/
drwxr-xr-x. 2 root root 17 Aug  5 13:05 /testdir/
[root@centos7 testdir]# su wang
[wang@centos7 testdir]$ ls
file
[wang@centos7 testdir]$ rm -f file
rm: cannot remove ‘file’: Permission denied
[wang@centos7 testdir]$ echo aaaaa>>file
bash: file: Permission denied
[wang@centos7 testdir]$

从上诉实验可知,不能删除和修改此文件

4、复制/etc/fstab文件到/var/tmp下,设置文件所有者为 wang读写权限,所属组为sysadmins组有读写权限,其他人无权限

[root@centos7 ~]# groupadd sysadmins
[root@centos7 ~]# getent group sysadmins
sysadmins:x:10012:
[root@centos7 ~]# cp /etc/fstab  /var/tmp/
[root@centos7 ~]# chown wang.sysadmins /var/tmp/fstab
[root@centos7 ~]# ll /var/tmp/fstab
-rw-r--r--. 1 wang sysadmins 507 Aug  5 13:11 /var/tmp/fstab
[root@centos7 ~]#

5、误删除了用户wang的家目录,请重建并恢复该用户家目录 及相应的权限属性

[root@centos7 ~]# cp /etc/skel/. /home/wang/ -r
[root@centos7 ~]# cd /home/wang
[root@centos7 wang]# ls -a
.  ..  .bash_logout  .bash_profile  .bashrc  .mozilla
[root@centos7 wang]# cd ../
[root@centos7 home]# ls -ld ./wang
drwxr-xr-x. 3 root root 74 Aug  5 13:13 ./wang
[root@centos7 home]# chown -R  wang.wang ./wang
[root@centos7 home]# chmod 700 ./wang/
[root@centos7 home]# ll
total 12
drwx------. 6 gentoo   gentoo   4096 Aug  4 13:36 gentoo
drwx------. 5 hadoop   hadoop   4096 Aug  3 22:17 hadoop
drwx------. 3 wang     wang       74 Aug  5 13:13 wang
drwx------. 5 xiaoming xiaoming 4096 Aug  5 09:54 xiaoming

6、设置user1,使之新建文件权限为rw——-

[root@centos7 ~]# useradd user1
[root@centos7 ~]#
[root@centos7 ~]# su user1
[user1@centos7 root]$ cd
[user1@centos7 ~]$
[user1@centos7 ~]$ vi ~/.bashrc
[user1@centos7 ~]$ umask
0002
[user1@centos7 ~]$ . ~/.bashrc
[user1@centos7 ~]$ umask
0066
[user1@centos7 ~]$ touch file.txt
[user1@centos7 ~]$ ll file.txt
-rw-------. 1 user1 user1 0 Aug  5 13:27 file.txt

7、设置/testdir/f1的权限,使user1用户不可以读写执行,g1组可以读写

[root@centos7 testdir]# touch f1
[root@centos7 testdir]# ll
total 0
-rw-r--r--. 1 root root 0 Aug  5 13:34 f1
-rw-r--r--. 1 root root 0 Aug  5 13:05 file
[root@centos7 testdir]# setfacl -m u:user1:0,g:g1:rw /testdir/f1
[root@centos7 testdir]# getfactl /testdir/f1
bash: getfactl: command not found...
[root@centos7 testdir]# getfacl /testdir/f1
getfacl: Removing leading '/' from absolute path names
# file: testdir/f1
# owner: root
# group: root
user::rw-
user:user1:---
group::r--
group:g1:rw-
mask::rw-
other::r--

8、/testdir/dir的权限,使新建文件自动具有acl权限:user1:rw,g1:—

[root@centos7 testdir]# mkdir dir
[root@centos7 testdir]# ll
total 4
drwxr-xr-x. 2 root root 6 Aug  5 13:39 dir
-rw-rw-r--+ 1 root root 0 Aug  5 13:34 f1
-rw-r--r--. 1 root root 0 Aug  5 13:05 file
[root@centos7 testdir]# setfacl -m d:u:user1:rw ./dir/
[root@centos7 testdir]# setfacl -m d:g:g1:0 ./dir/
[root@centos7 testdir]# getfacl ./dir/
# file: dir/
# owner: root
# group: root
user::rwx
group::r-x
other::r-x
default:user::rwx
default:user:user1:rw-
default:group::r-x
default:group:g1:---
default:mask::rwx
default:other::r-x

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

[root@centos7 testdir]# rm -rf /data/testdir/
[root@centos7 testdir]#
[root@centos7 testdir]# mkdir -p /data/testdir/
[root@centos7 testdir]# ll /data/testdir/
total 0
[root@centos7 testdir]# ls -ld /data/testdir/
drwxr-xr-x. 2 root root 6 Aug  5 13:44 /data/testdir/
[root@centos7 testdir]# useradd alice
[root@centos7 testdir]# useradd tom
[root@centos7 testdir]# chmod g+s /data/testdir/
[root@centos7 testdir]# ls -ld /data/testdir/
drwxr-sr-x. 2 root root 6 Aug  5 13:44 /data/testdir/
[root@centos7 testdir]# chown .g1 /data/testdir/
[root@centos7 testdir]# ls -ld /data/testdir/
drwxr-sr-x. 2 root g1 6 Aug  5 13:44 /data/testdir/
[root@centos7 testdir]# gpasswd -g g2 -a alice
Adding user alice to group g2
[root@centos7 testdir]# gpasswd -g g3 -a tom
Adding user tom to group g3
[root@centos7 testdir]# setfacl -m d:g:g2:rw /data/testdir/
[root@centos7 testdir]# setfacl -m d:g:g3:r /data/testdir/
[root@centos7 testdir]# getfacl /data/testdir/
getfacl: Removing leading '/' from absolute path names
# file: data/testdir/
# owner: root
# group: g1
# flags: -s-
user::rwx
group::r-x
other::r-x
default:user::rwx
default:group::r-x
default:group:g2:rw-
default:group:g3:r--
default:mask::rwx
default:other::r-

每天总结博客地址:http://purify.blog.51cto.com/

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

(0)
alrenalren
上一篇 2016-08-05 16:09
下一篇 2016-08-05 16:09

相关推荐

  • 压缩工具

     压缩和解压缩工具和bash脚本编程      压缩比        目的:时间换空间        cpu的时间—>磁盘空间        compress/uncompress.…

    Linux干货 2016-12-31
  • 内部命令与外部命令

    内部命令与外部命令 内部命令在系统启动时就调入内存,是常驻内存的,所以执行效率高。 外部命令是系统的软件功能,用户需要时才从硬盘中读入内存。 1.type type COMMAND 判断一个命令的类型即判断一个命令是否为内置命令。   2.enable(内部命令) enable既可以查看内部命令,同时也可以判断是否为内部命令 enable 显示所有…

    2017-07-15
  • N21天天第十一周课程练习

    1、详细描述一次加密通讯的过程,结合图示最佳。 SSL协议基础: SSL协议位于TCP/IP协议与各种应用层协议之间,本身又分为两层: 1)SSL记录协议:建立在可靠传输层协议(TCP)之上,为上层协议提供数据封装、压缩、加密等基本功能。 2)SSL握手协议:在SSL记录协议之上,用于实际数据传输前,通讯双方进行身份认证、协商加密算法、交换加密密钥等。 SS…

    Linux干货 2016-10-09
  • 权限解析

    一、文件权限        用户的创建的每个文件,都有自己特定的属性信息,比如文件类型,文件的权限,文件的所有者和所属组,以及文件的修改日期等属性组成。        文件的权限即是指文件本身赋予了用户什么样的权力,也就…

    2017-05-30
  • web服务 初步

    Web Service初步 一、引言 Web服务也是一个C/S架构,服务器端就是一个进程,客户端是一个浏览器。我们打开浏览器的时候,都会看到hppt,https的字样,然后才是输入网址,这两个协议是web服务的应用层协议,用来实现某些具体应用的。像https,前面学习openssl的时候也接触过,https=http+ssl。 web的传输层协议用到了tcp…

    Linux干货 2016-12-09
  • 【社招】【小米-北京】大数据运维工程师

    【社招】【小米-北京】大数据运维工程师 【工作地点】北京市海淀区安宁庄东路72号科利源大厦 【薪酬福利】15k-30k  期权奖励、六险一金、水果花茶、班车、健身房、食堂 【投递方式】邮件主题“岗位+姓名”发送至[email protected]   工作职责: 1、负责大数据平台相关系统的运维保障,包括:Hadoo…

    Linux干货 2017-07-28