1. ACL permissions
effect:
When a user needs to set permissions that user, group, and other cannot satisfy, you can use the ACL command to set them individually.
A file or directory with ACL permissions set, displayed as rwxr-xr-x +
Order:
Check acl permissions:
getfacl
Set ACL permissions:
setfacl, -m, modify
assign permissions:
Assign permissions to user, setfacl -mu:user1:rwx /tmp/test, which means user1 assigns rwx permissions to the /tmp/test folder
For example, to assign permissions to group, setfacl -mg:group1:rwx /tmp/test, which means to assign rwx permissions to the /tmp/test folder for group1
Set the default maximum authority: mask is the maximum authority
setfacl -m m:rx /tmp/test
Set recursive permissions, -R, only on directories
setfacl -m u:user1:rwx -R /tmp/test
Set default permissions, only for directories
setfacl -m d:u:user1:rwx -R /tmp/test
Remove a permission:
setfacl -x u:user1 /tmp/test
Remove all permissions:
setfacl -b /tmp/test
Second, special permissions
Function: enable ordinary users or groups to temporarily obtain the root permission of an executable file, that is, SUID or SGID permission, such as passwd; enable users to delete files created by themselves in a certain folder, that is, sticky bit permissions, such as / tmp
设置了SUID或SGID的可执行文件,显示为s,如
-rwsr-xr-x. 1 root root 27832 Jan 29 2014 /usr/bin/passwd
设置了黏着位的目录,显示为t,如
drwxrwxrwt. 11 root root 4096 Jun 6 22:37 /tmp
设置特殊权限:
4代表SUID权限,2代表SGID权限,1代表黏着位权限,s表示SUID或SGID,t表示黏着位权限即Sticky BIT
chmod 4755 /tmp/test
chmod u+s /tmp/test
去除特殊权限:
chmod 755 /tmp/test
chmod u-s /tmp/test
注意,赋予SUID权限很危险,如vi命令有SUID权限,意味着所有普通用户都可以用vi察看并修改只有管理员才能看和修改的文件
注意,SGID也可对于目录,作用是,如果普通用户在该目录创建文件,则该文件的所属组不再是创建者的用户组,而是root组
三,文件属性
作用:对文件设置属性,对于root也生效,可用于保护重要文件
察看文件属性:
lsattr
设置文件属性:
chattr [+-=] 选项 文件名或目录
选项:
i : 对于文件,意为该文件将不允许删除,改名,添加和修改数据 ;对于目录,意为不能在该目录中创建和删除文件,但可以修改已存在的文件的内容 --用于锁定重要文件,防止普通用户甚至root的误操作
a : 对于文件,意为该文件只能增加数据,不能删除和修改数据 ; 对于目录,意为只允许建立,修改文件,不能删除文件 --用于保护文件原有内容
四,sudo权限
作用:某个普通用户拥有root权限去执行命令
visudo,实际修改的是/etc/sudoers文件
/etc/sudoers配置文件格式:
用户名 权限所在机器的IP=具体授权的命令甚至参数
使用sudo:
sudo 命令绝对路径 参数
注意,不要给vi赋予sodu权限,获得的权限不光是执行vi的权限,也会获得用vi打开并修改只有root才能看到和修改到的文件