Get a list of all files and their attributes on OS X

3

1

What is the best and fastest way to get a list of every file on OS X including hidden and system files along with their attributes? I'm not afraid of the terminal or scripts, but if there is a wonderful audit-like application out there I'd be interested in comparing that to my options.

Michael Prescott

Posted 2009-11-25T01:33:17.367

Reputation: 3 351

Answers

2

Depends on what attributes you need, but the standard unix way would be:

find / -type f -print0 | xargs -0 stat

You mention auditing, so something like tripwire may fit your needs better.

Geoff Fritz

Posted 2009-11-25T01:33:17.367

Reputation: 949

For me, the results are without extended attributes. – Graham Perrin – 2012-07-17T06:05:08.267

1I would also recommend adding the > all_my_files.txt at the end. That way you can view the data at a later date too. – ricbax – 2009-11-25T02:22:31.700

1Why pipe to tough xargs? Why not find /path/to/search/ -type f -exec stat {} \; ? – Hennes – 2013-09-30T22:50:19.077

2

To list extended attributes and file flags for all files on all devices:

sudo find / -exec ls -ldO@ {} \;

(that's an upper case letter O in the "-ldO@").

To include access control lists (ACLs), the -e option of ls:

sudo find / -exec ls -ldeO@ {} \;

If a device is a Filesytem in Userspace with no allowance for root, then the commands above will not succeed for that device.

For the listing to exclude devices other than the startup volume, the -x option of find:

sudo find -x / -exec ls -ldeO@ {} \;

Marnix A. van Ammers

Posted 2009-11-25T01:33:17.367

Reputation: 1 978

0

You can use mdfind.

Find files matching a single query.

user31894

Posted 2009-11-25T01:33:17.367

Reputation: 2 245

mdfind does list some system files that the Spotlight menu and Finder don't, but there are some files that don't even seem to be indexed by Spotlight. You can also include some additional hidden files in the mdfind results by setting kMDItemFSInvisible to true. – Lri – 2012-07-17T17:05:05.663

mdfind does not search system directores by default. – Chealion – 2009-11-25T02:21:20.673

so that means you can set something to let it search for system directories, right? – user31894 – 2009-11-27T10:56:06.393