文件查找
locate:
非实时,模糊匹配查找全系统文件数据库
find:
实时
精确
支持众多查找标准
遍历指定目录中所有文件查找,速度慢
find 查找路径 查找标准 查找到后的处理操作
处理运作:默认为显示
find /etc -name 'passwd' 精确匹配
*
?
[]
-iname 文件名匹配不区分大小写
-regex PATTERN
-user 根据属主查找
-group
-uid 用户被删除后文件属于用户的id
-gid
-nouser
-type
f
d
c
b
l
p
s
-size
[+-]#k
[+-]#M
[+-]#G
组合条件
-a 默认
-o
-not
find /tmp -not -type d
find ./ -not \(-user user1 -o -user user2\)
-mtime modify
-atime access
-ctime create
-mmin
-amin
-cmin
[+-]number
-perm MODE
-MODE每一位都匹配
/MODE任意一组ugo匹配
-644
-print 显示
-ls
-ok COMMAND
-exec
find ./ -perm -002 -exec mv {} {}.new\; 原来文件名后加.new
find /etc -size +1M | xargs echo {} >> /tmp/etc.largefiles
特殊权限
suid 无论哪个用户启动进程,该进程的属主都是文件的sid
chmod u+s
如果file本身有x权限,则SUID显示为s,否则显示S
chmod u-s
sgid
chmod g+s
chmod g-s
sticky
在一个公共目录,每个都可以创建文件,删除自己文件,不能删除别人的文件
chmod o+t
chmod o-t
chmod 1755 (suid,sgid,sticky)
suid,sgid,sticky(3 bits)
000
001
010
...
...
...
111
umask 0022
set user identification / set group identifaication / set sticky bit
rwx-rwx-rwx
u :来说 rwx 的 x 显示为 s 时,表示设置了 suid 且开启了 execute 权限;x 显示为 S 表示设置了 suid 但没有开启 execute 权限。
g :来说 rwx 的 x 显示为 s 时,表示设置了 guid 且开启了 execute 权限;x 显示为 S 表示设置了 guid 但没有开启 execute 权限。
u :来说 rwx 的 x 显示为 t 时,表示设置了 sticky 且开启了 execute 权限;x 显示为 T 表示设置了 sticky 但没有开启 execute 权限。
也就是一个文件的完整权限其实是用 12 位来表示的。
https://www.thegeekdiary.com/what-is-suid-sgid-and-sticky-bit/