权限作业

  • 三种权限rwx对文件和目录的不同意义

    对文件来说:
    r:可获取文件的数据;
    w:可修改文件的数据;(但不能删除文件)
    x:可将此文件运行为进程;(针对二进制文件或脚本)
    (一般而言,文件默认情况下都不该有执行权限)
    对目录来说:
    r:可以使用ls获取其下的所有文件列表;但不能访问文件,不能cd进目录,不能查看文件的详细信息(元数据)
    w:可修改此目录下的文件列表;即创建或删除文件;需要配合x权限来操作
    x:可cd至此目录中,且可使用ls-l来获取所有文件的详细属性信息;可以访问目录中的文件	
  • umask和acl mask 的区别和联系

    umask命令用来设置限制新建文件权限的掩码
    acl musk 也可以用来限制权限,这是他们的联系
      区别:      
     umask与mask的区别感觉就是mask是给权限设置了一个界限,除了root和文件所有者和other外的其他用户或者组不能超过他设置的权限界限,
     只能低于或者等于。而umask是给定一个模式,只要用户创建目录或者文件,其所得到的权限是一定的。
  • 三种特殊权限的应用场景和作用

    当一个用户执行一个二进制文件权限不够时可以用SUID权限。SUID只能运用在二进制可执行文件上,当用户执行该执行文件时,会临时拥有该执行文件所有者的权限
      当多个用户属于同一项目组,或者需要对同一目录的文件或者子目录都可以自由操作时,可以用SGID权限。SGID可以应用在目录或可执行文件上。当SGID应用在文件上时,用户访问该文件时执行的是文件所属组的操作权限。
      当SGID应用在目录上时,该目录中所有新建立的文件或子目录的属组都会是该目录的属组
      Sticky权限只能应用在目录,当目录拥有Sticky所有在该目录中的文件或子目录无论是什么权限只有文件或子目录所有者和root用户能删除。
  • 设置user1,使之新建文件权限为rw——-

    [user1@localhost ~]$ nano /home/user1/.bashrc          
      # .bashrc
      
      # Source global definitions
      if [ -f /etc/bashrc ]; then
              . /etc/bashrc
      fi  
      # Uncomment the following line if you don't like systemctl's auto-paging feature:
      # export SYSTEMD_PAGER=
      
      # User specific aliases and functions
      
      umask 066
    
    
      [user1@localhost ~]$ 
      [user1@localhost ~]$ umask  0066
      [user1@localhost ~]$ touch f2
      [user1@localhost ~]$ ll f2
      -rw------- 1 user1 user1 0 Aug  4 20:26 f2
  • 设置/testdir/f1的权限,使user1用户不可以读写执行,g1组可以读写 /testdir/dir的权限,使新建文件自动具有acl权限:user1:rw,g1:— 备份/testdir目录中所有文件的ACL,清除/testdir的所有ACL权限,并利用备份还原

    [root@localhost ~]# mkdir testdir
      [root@localhost ~]# touch testdir/f1
      [root@localhost ~]# setfacl -m u:user1:0 testdir/f1
      [root@localhost ~]# mkdir testdir/dir
      [root@localhost ~]# groupadd g1
      groupadd: group 'g1' already exists
      [root@localhost ~]# setfacl -m g:g1:rw tsetdir/dir
      setfacl: tsetdir/dir: No such file or directory
      [root@localhost ~]# setfacl -m g:g1:rw testdir/dir
      [root@localhost ~]# setfacl -Rm d:u:user1:rw testdir
      [root@localhost ~]# setfacl -Rm d:g:g1:0 testdir
      [root@localhost ~]# touch testdir/f2
      [root@localhost ~]# getfacl testdir/f2
      # file: testdir/f2
      # owner: root
      # group: root
      user::rw-
      user:user1:rw-  group::r-x			#effective:r--
      group:g1:---  mask::rw-
      other::r--
      
      [root@localhost ~]# getfacl testdir/f1
      # file: testdir/f1
      # owner: root
      # group: root
      user::rw-
      user:user1:---  group::r--
      mask::r--
      other::r--
      
      [root@localhost ~]# getfacl testdir/dir
      # file: testdir/dir
      # owner: root
      # group: root
      user::rwx
      group::r-x
      group:g1:rw-  mask::rwx
      other::r-x
      default:user::rwx
      default:user:user1:rw-  default:group::r-x
      default:group:g1:---  default:mask::rwx
      default:other::r-x
      
      [root@localhost ~]# getfacl testdir
      # file: testdir
      # 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
      [root@localhost ~]# getfacl -R testdir > file.acl
      [root@localhost ~]# cat file.acl
      # file: testdir
      # 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
      
      # file: testdir/f1
      # owner: root
      # group: root
      user::rw-
      user:user1:---  group::r--
      mask::r--
      other::r--
      
      # file: testdir/dir
      # owner: root
      # group: root
      user::rwx
      group::r-x
      group:g1:rw-  mask::rwx
      other::r-x
      default:user::rwx
      default:user:user1:rw-  default:group::r-x
      default:group:g1:---  default:mask::rwx
      default:other::r-x
      
      # file: testdir/f2
      # owner: root
      # group: root
      user::rw-
      user:user1:rw-  group::r-x	#effective:r--
      group:g1:---  mask::rw-
      other::r--
      
      [root@localhost ~]# setfacl -R -b testdir
      [root@localhost ~]# getfacl testdir
      # file: testdir
      # owner: root
      # group: root
      user::rwx
      group::r-x
      other::r-x
      
      [root@localhost ~]# setfacl -R --set-file=file.acl testdir
      [root@localhost ~]# getfacl -R testdir
      # file: testdir
      # owner: root
      # group: root
      user::rw-
      user:user1:rw-  group::r-x			#effective:r--
      group:g1:---  mask::rw-
      other::r--
      default:user::rwx
      default:user:user1:rw-  default:group::r-x
      default:group:g1:---  default:mask::rwx
      default:other::r-x
      
      # file: testdir/f1
      # owner: root
      # group: root
      user::rw-
      user:user1:rw-  group::r-x			#effective:r--
      group:g1:---  mask::rw-
      other::r--
      
      # file: testdir/dir
      # owner: root
      # group: root
      user::rw-
      user:user1:rw-  group::r-x			#effective:r--
      group:g1:---  mask::rw-
      other::r--
      default:user::rwx
      default:user:user1:rw-  default:group::r-x
      default:group:g1:---  default:mask::rwx
      default:other::r-x
      
      # file: testdir/f2
      # owner: root
      # group: root
      user::rw-
      user:user1:rw-  group::r-x			#effective:r--
      group:g1:---  mask::rw-
      other::r--

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

(0)
dxkbokedxkboke
上一篇 2016-08-05
下一篇 2016-08-05

相关推荐

  • Linux无人值守安装

    前言     通常情况下,我们安装Linux操作系统的时候需要从光盘启动,通过系统光盘bootloader启动安装程序,进入交互式安装模式,由用户配置安装选项,如磁盘分区、选择安装包等操作;安装完毕后重启结束安装。在生产环境中,成百上千台服务器需要安装操作系统的时候如果也采用交互式安装模式,无疑是极其低效的。本文主要介…

    Linux干货 2015-05-18
  • HAproxy reload config file with uninterrupt session

    HAProxy is a high performance load balancer. It is very light-weight, and free, making it a great option if you are in the market for a load balancer and need to keep your cos…

    Linux干货 2015-04-03
  • N26-第一周博客作业

    1、计算机的组成及功能     CPU: Central Processing Unit 运算与管理控制功能        包括:          &nbsp…

    Linux干货 2017-01-10
  • 搭建私有CA服务器

       CA(Certificate Authority)证书颁发机构主要负责证书的颁发、管理以及归档和吊销。证书内包含了拥有证书者的姓名、地址、电子邮件帐号、公钥、证书有效期、发放证书的CA、CA的数字签名等信息。证书主要有三大功能:加密、签名、身份验证。下面来看一下自建CA的过程    一、建立CA服务器 &nbsp…

    Linux干货 2016-03-14
  • SNAT,DNAT,端口转发

    利用iptables配置NAT

    2018-03-01
  • 第10周作业(上)

    第10周作业 1、请详细描述CentOS系统的启动流程(详细到每个过程系统做了哪些事情)。CentOS系统启动详细的过程如下(以CentOS7为例): 加电自检(POST)按下电源开关,BIOS系统随即开始加电自检,检查CPU、内存、主板及各接口、硬盘、键盘、光驱等,检测它们的好坏。 读取启动顺序检查完成后,BIOS会根据预先设定好的启动顺序去挨个寻找可引导…

    Linux干货 2017-01-03