find根据文件属主或权限进行操作

很多时候,当用户离开,组织变更后,管理员会删除这些用户或组。
但之前的这些用户的文件属性就直接显示成数字uid,gid 。
利用find 可以重新将这些文件归类。
查找存在的用户的文件

find /home   -user  x  -ls
find /home -user x  -group x2  -ls

查找销户的文件

find /home -nouser -ls
find /home -nogroup -ls
指定uid,gid
find /home -uid xxx   -gid xxx -ls

根据权限 -perm查找 ,suid 4000,sgid 2000

find /home -perm 775  -type f -ls
find /home -perm 4000 -type d -ls
find /home -perm 2000 -type d -ls
find /home -perm 6000 -type f -ls 

根据nouser,uid查找,并赋给新的主用户或删除

find /home -nouser  -exec chown x.g  {}  \;
find /home -uid 1010 -exec chown x.g {} \;
find /home -uid 1010  -ok rm {} \;

猜你喜欢

转载自blog.csdn.net/CSDN1887/article/details/84336120