常规权限:
r read 读取 4
w write 写入 2
x execute 执行 1
文件 :
r 查看文件内容(cat/more/less/head/tail/grep)
w 编辑文件内容(vim)
x shell/python脚本
目录 :
r 查看目录下的文件(ls /tmp)
w 修改目录下的文件(新建、删除、mv)
x 切换目录 (cd)
查看文件权限
查看目录权限
[root@192 ~]# ls -ld /etc/
drwxr-xr-x. 140 root root 8192 May 3 14:09 /etc/
设置文件目录权限
1)chmod
chmod {augo}{±=}{rwx} 文件名称
a all 所有
u user 属主用户权限
g group 属组
o other 其他
#chmod a+x /tmp/1.txt
#chmod u-x,o+r /tmp/2.txt
[root@192 huge]# chmod a+x 1.txt
[root@192 huge]# chmod u-x,o+r 2.txt
[root@192 home]# chmod g=rw /home/huge/3.txt
# chmod nnn 文件名称
[root@192 home]# chmod 600 /home/huge/4.txt
- 修改文件的属主、属组
chown 用户名称、用户组名称 文件名称
[root@192 home]# chown user1.caiwu /home/huge/1.txt
>>> 更改用户的属主及属组1.text
[root@192 home]# chown user2 /home/huge/2.txt
>>> 更改用户的属主
[root@192 huge]# chgrp caiwu 2.txt
>>> 更改用户的属组
3)facl ----- 文件访问控制列表
设置权限
针对单个用户
# setfacl -m u : 用户名: 权限 文件名称
[root@192 huge]# setfacl -m u:user4:r 3.txt
>>> 把3.txt文件的读权限赋给user4
[root@192 huge]# getfacl 3.txt
>>> 查看.txt文件的ACL权限
针对单个用户删除权限:
[root@192 huge]# setfacl -x u:user4 3.txt
>>> 把user4的acl 权限删掉
针对单个用户组
setfacl -m g : 用户组名:权限 文件名称
针对单个用户组删除权限
setfacl -x g:用户组名称 文件名称