Is it possible to create a script to save and restore permissions?

前端 未结 13 1478
逝去的感伤
逝去的感伤 2021-01-30 04:29

I am using a linux system and need to experiment with some permissions on a set of nested files and directories. I wonder if there is not some way to save the permissions for t

13条回答
  •  轮回少年
    2021-01-30 05:13

    hm. so you need to 1) read file permissions 2) store them somehow, associated to each file 3) read your stored permissions and set them back

    not a complete solution but some ideas:

    stat -c%a filename
    >644
    

    probably in combination with

    find -exec
    

    to store this information, this so question has some interesting ideas. basically you create a temporary file structure matching your actual files, with each temp file containing the file permissions

    to reset you iterate over your temp files, read permissions and chmod the actual files back.

提交回复
热议问题