find根據檔案屬主或許可權進行操作

2021-09-01 12:54:10 字數 785 閱讀 2432

很多時候,當使用者離開,組織變更後,管理員會刪除這些使用者或組。

但之前的這些使用者的檔案屬性就直接顯示成數字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 *** -gid *** -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 {} \;

Linux檔案許可權,屬主,屬組等

在linux檔案中,每乙個資料夾或者是檔案,都有許可權進行控制其是否可讀,可寫,可執行。並且對操作者的許可權也有設定。今天學習了該部分內容,做乙個記錄。首先,指令 ll 看一年linux下的乙個資料夾內容 r w x 是否可讀,是否可寫,是否可執行。總結一下如下 r w x r w x r w x ...

linux修改檔案屬主以及檔案許可權

linux系統使用者可分為以下三類 u user即檔案或目錄的擁有者 g group即檔案或目錄的所屬組 o other除了檔案或目錄擁有者或所屬組之外,其他使用者皆屬於這個範圍 a all即全部的使用者,包含擁有者,所屬群組以及其他使用者 chown 改變檔案屬主 chown username f...

rsync 同步檔案如何指定屬主屬組和許可權

rsync daemon 同步資料時,若想同時指定許可權和屬主屬組,可以做如下配置 test1 uid admin gid admin incoming chmod dug rwx,do rx,fug rw,fo r incoming chmod d775,f664 outgoing chmod d...