2016/09/05

Published 9月 05, 2016 by

備份及回存Linux的權限及Owner

備份及回存Linux的權限及Owner

備份權限及Owner:
find * -depth -exec stat --format '%a %u %g %n' {} + >/tmp/save-the-list

回存權限及Owner:
 while read PERMS OWNER GROUP FILE 
 do 
     chmod "$PERMS" "$FILE" 
     chown "${OWNER}:${GROUP}" "$FILE" 
 done </tmp/save-the-list 

保存的檔案內容如下(以相對目錄存放)
目前權限 Owner Group Directory/file
775 2001 2001 test_file/old_version
644 2001 2001 tester_file/direct.sh
644 0 0 tes_file/123.sh
644 2001 2001 test_file/update.sh
755 2001 2001 test_file

Reference: