How to backup file permissions

Owen Townend owen.townend at
Thu Apr 24 13:36:11 BST 2008

On 24/04/2008, ml at <ml at> wrote:
> Hello List,
> is there an way to backup file permissions (not the actual files!!).
> I need it for some bash script.
> Thanks, Mario


  Something simple like this to save
# find . -printf '%p %m \n' > permissions.out
  Then something like this to restore
# awk '{system("chmod "$2" "$1)}' permissions.out

  Simple, easy to read, plaintext backup.
  It wouldn't be hard to add ownership to this if you want/need that too.

# find . -printf '%p %m %u %g \n' > permissions.out
# awk '{system("chmod "$2" "$1), system("chown "$3":"$4"
"$1)}' permissions.out

  This doesn't support filenames with spaces as it stands, but hopefully
works as a proof of concept...


> ubuntu-users mailing list
> ubuntu-users at
> Modify settings or unsubscribe at:
-------------- next part --------------
An HTML attachment was scrubbed...

More information about the ubuntu-users mailing list