Backup, restore file permissions

cool_penguin_smallBacking up permissions of a filesystem can be useful if you want to revert back to your original permissions after someone else runs the following somewhere in your filesystem tree:

$ chmod -R 777 .

There are at least two ways you backup your filesystem permissions.

1. pbackup

pbackup is a very old tool for Unix based systems. It shows the mode_t 16-bit value of a file’s stat information in the standard output. The same information can be stored in a file using redirection.


  -S       generate backup data from file(s), dump to stdout
  -R       restore permissions from backup through stdin
  -C       check current file permissions against backup
  -r       be recursive (save mode only)
  -v       be verbose (restore mode only)
  -m <num> max open file descriptors when being recursive (default is 64)
  -V       print version and exit


  • Create backup data:
    $ pbackup -S -r ~/user >
  • Check permission integrity:
    $ pbackup -C <
  • Restore from backup:
    $ pbackup -R <

pbackup is not installed by default on Linux systems. Find the binary compiled on Ubuntu 14.04 amd64 here.
md5sum: baf69a372ddd7237a3e4af42f8097182

2. ACL backup

Modern Linux systems support Access Control Lists for more fine-grained control information on files. There are two in-built utilities which backup the ownership information in addition to the generic permissions.

  • Take snapshot of ACL:
    $ getfacl -R ~/user >
  • Restore ACL snapshot:
    $ setfacl

One thought on “Backup, restore file permissions”

Leave a Reply

Your email address will not be published. Required fields are marked *