用户的基本权限

用户的基本权限

一、基本权限UGO

1、概述

赋于某个用户或组 能够以何种方式 访问某个文件(图片文件,视频文件,普通文件)如:QQ空间的红钻特权

2、权限对象

属主: u

属组: g

其他人: o

所有人:a(u+g+o)

3、权限类型

读:r=4

写:w=2

执行: x=1

4、查看权限

查看权限记录

[root@localhost ~]#ls  -l  /root/1.txt

-rw-r--r--.   1   root root  179  5月  25  14:27  /root/1.txt

-文件类型

 rw-主人的权限,属主  r--属组的权限,  r--其他人的权限

5、设置权限

、语法

使用符号:u用户 g组  o其他  r读   w写  x执行  chmod   对象(u/g/o/a)赋值符(+/-/=)权限类型(r/w/x)    文件/目录

、了解普通文件的基本权限

[root@localhost ~]# cd  /tmp

[root@localhost ~]# touch     file1

[root@localhost tmp]# ll file1

-rw-r--r--. 1 root root 0 4月  13 20:49 file1

权限         属主 属组              文件

、增加执行权限

[root@localhost tmp]# chmod u+x file1

、更多的修改权限

 

[root@localhost tmp]# chmod        a=rwx    file1 //所有人等于读写执行

[root@localhost tmp]# chmod        a=-       file1 //所有人没有权限

[root@localhost tmp]# chmod       ug=rw,o=r       file1 //属主属组等于读写,其他人只读

[root@localhost tmp]# ll file1 //以长模式方式查看文件权限

-rw-rw-r-- 1 alice it 17 10-25 16:45 file1 //显示的结果

、使用数字设置权限

4读   2写   1执行

[root@localhost ~]# chmod 644 file1

[root@localhost ~]# ll file1

-rw-r--r-- 1 alice it 17 10-25 16:45 file1

6、更改属主、属组

、chown命令

chown: 设置一个文件属于谁,属主

语法: chown   用户名.组名   文件

[root@localhost ~]# chown alice.hr file1   //改属主、属组

[root@localhost  ~]# chown alice file1  //只改属主

[root@localhost ~]# chown .hr file1    //只改属组

[root@localhost ~]#chown -R   user1.user2  /tmp/dir1/file1.txt   //修改文件夹下的文件的属主属组

、chgrp命令

语法:            chgrp   组名   文件      -R是递归的意思

[root@localhost ~]# chgrp it file1 //改文件属组

[root@localhost ~]# chgrp -R it dir1 //改文件属组

二、基本权限 ACL

1、区别

ACL文件权限管理: 设置不同用户,不同的基本权限(r、w、x)。对象数量不同。

UGO设置基本权限: 只能一个用户,一个组和其他人

2、语法

setfacl    -m      u:alice:rw                     /home/test.txt

命令       设置      用户或组:用户名:权限    文件对象

3、用法

、准备文件

[root@localhost ~]# touch /home/test.txt

[root@localhost ~]# ll /home/test.txt

-rw-r--r-- 1 root root 0 10-26 13:59 /home/test.txt

、设置ACL

设置用户alice,jack权限:前提:创建alice 和jack用户。过程略  

[root@localhost ~]# setfacl -m u:alice:rw /home/test.txt

[root@localhost ~]# setfacl -m u:jack:- /home/test.txt

[root@localhost ~]# setfacl -m o::rw /home/test.txt   设置文件其他人访问权限

4、查看/删除

、查看ACL

[root@localhost ~]# getfacl /home/test.txt

、删除ACL

[root@localhost ~]# setfacl -x g:hr /home/test.txt   //删除组hr的acl权限

[root@localhost ~]# setfacl -b /home/test.txt        //删除所有acl权限

 

 

 


猜你喜欢

转载自blog.51cto.com/15135903/2666668