文件权限
1.文件属性的查看
ls -l filename
2.文件所有人所有组的管理
chown username file|dir
chgrp groupname file|dir
chown -R username dir /更改目录本身及里面所有内容的所有人
chgrp -R groupname dir/更改目录本身及里面所有内容的所有组
监控命令
watch -n 1 ls -lR mnt
3.文件普通权限
rw-|r–|r–
u g o
u:文件所有人对文件可读
g:文件组成员对文件可度
o:其他人对文件可读
u优先匹配,g次优先,o当u,g不匹配时匹配
4.字符方式修改该文件的权限
chmod u-x file1 /file1拥有着去掉x权限
chomd g+w file1/file1拥有组添加w权限
chomd u-x,g+w file1
chomd ugo-r file2/file2用户组其他人去掉r权限
chomd ug+x,o-r file3 /file3用户和组添加x权限,其他人去掉r权限
5.数字修改该文件权限
chomd 777 file
4.系统默认权限的设定
umask 默认权限为022
umask 077 /临时设定,只在当前shell中生效
vim /etc/bashrc //shell
vim /etc/profile //系统
以上两个文件umask必须保持一致
source /etc/bashrc
source /etc/profile
让设定立即生效
setfacl -m d:u:student:rwx /westos
给student用户以所有人的身份对westos可以进行rwx
getfacl /westos /表示westos目录有权限列表
6.特殊位限
1.suid /冒险位
设定方法
chmod u+s file
suid=4
chmod 4xxx file
只针对二进制可执行文件 /mnt which touch
文件记录程序产生的进程的所有人为文件所有人和进程发起人身份无关
2.sgid /强制位
设定方法
chmod g+s file|dir
sgid=2
chmod 2xxx file|dir
只针对二进制可执行文件
文件记录程序产生的进程的所有组为文件所有组和进程发起人组的身份无关
3.sticky/粘制位
t权限
只针对目录,当一个目录上有t权限时,那么目录中的文件只能被文件拥有者删除
设定方法
chmod o+t direcotry
t=1
chmod 1777 direcotry
没加权限之前