How to map all filesystem permissions ( ACL only )

Share your own howto's etc. Not for support questions!

How to map all filesystem permissions ( ACL only )

Postby jlambrecht » 2015-05-08 14:06

Because i ran into this stupid stupid situation of having all files on a system chown and chmod ( because .* expands .. into the upper directory )

The below command should be ran as root or other privileged user if need be. This will print all ACL based information on the filesystem and dump it into a compressed file. Take note the compression factor is HUGE. I saw a 12MB file be compressed into a 512KB .gz file.

find / -printf path,%h,filename,%f,symlink,%l,userinfo,%u,%U,groupinfo,%g,%G,octaperms,%#m,hardlinks,%n"\n" -path /proc -prune -path /sys -prune | gzip > myfs.txt.gz

* the "-path /..... -prune" servers to exclude /proc and /sys from being indexed

Take note the process is far from efficient and may require quite a bit of time to complete. After this however restoring the filepermissions as recorded at the time this .gz was created should be trivial. Since this is a named CSV it should be quite easy to parse, feel free to leave out any of the non % values upto "\n" for faster result. The full option as above took about 13 minutes to create a db of 404509 files, the db size is 2.7M
Embrace what you're not certain off,
keep an eye on what you're confident about.
Posts: 374
Joined: 2008-02-01 16:21

Return to Docs, Howtos, Tips & Tricks

Who is online

Users browsing this forum: No registered users and 7 guests