suid sgid sbit chattr lsattr find

时间:2022-12-02 14:38:55

suid 一般用于二进制可执行文件不可用于shell脚本和目录,suid代表当用户执行此二进制文件时,暂时具有此文件所有者的权限 chmod 4xxx binfile

sgid 一般用于目录,sgid代表当其他用户在此目录下创建文件时其所有者为创建此目录的用户但所属组为设置sgid的用户 chmod 2xxx dir

sbit  一般用于目录,sbit代表用户在此目录创建的文件或目录只有自己和root才可以删除

suid sgid sbit的设置可以用命令chmod 4xxx 2xxx 1xxx 设置 但取消最好用chmod u-s g-s 取消数字无法生效

chattr +a 只能追加内容不能删除修改(root也不可以)+i不能对文件进行任何更改 若要操作只能先取消chattr -a

lsattr 查看文件的隐藏权限

find 命令

[root@ha-master test]# ll
总用量 0
-rw-r--r-- 1 root root 0 1月 8 18:49 0days
-rw-r--r-- 1 root root 0 1月 7 18:48 1days
-rw-r--r-- 1 root root 0 1月 6 18:48 2days
-rw-r--r-- 1 root root 0 1月 5 18:48 3days
-rw-r--r-- 1 root root 0 1月 4 18:48 4days
-rw-r--r-- 1 root root 0 1月 3 18:48 5days
-rw-r--r-- 1 root root 0 1月 2 18:48 6days
-rw-r--r-- 1 root root 0 1月 1 18:48 7days

find . -mtime +3 -type f -exec ls -l {} \;结果为

-rw-r--r-- 1 root root 0 1月 4 18:48 4days
-rw-r--r-- 1 root root 0 1月 3 18:48 5days
-rw-r--r-- 1 root root 0 1月 2 18:48 6days
-rw-r--r-- 1 root root 0 1月 1 18:48 7days

find . -mtime -3 -type f -exec ls -l {} \;结果为

-rw-r--r-- 1 root root 0 1月 8 18:49 0days
-rw-r--r-- 1 root root 0 1月 7 18:48 1days
-rw-r--r-- 1 root root 0 1月 6 18:48 2days

find . -mtime 3 -type f -exec ls -l {} \;结果为

-rw-r--r-- 1 root root 0 1月 5 18:48 3days