find files with ACLs set

15

5

How can I find all files with some extended ACLs set, i.e. those with a little + at the end of the permission flags shown by ls -l.

I could not find a corresponding flag for find. My naive approach would be a find combined with ls -l and a grep. But I don't think this is nice.

Does someone have an idea?

Speckinius Flecksis

Posted 2012-03-08T14:49:35.537

Reputation: 313

Answers

15

getfacl can dump ACLs recursively, and it has a --skip-base option for ignoring files without ACLs.

getfacl -R -s -p /directory | sed -n 's/^# file: //p'

user1686

Posted 2012-03-08T14:49:35.537

Reputation: 283 655

0

Perl version:

getfacl -R -p -s  / | perl -wn -e ' if (/^# file/) { s|^# file: /||; print; }'

Nicola Mingotti

Posted 2012-03-08T14:49:35.537

Reputation: 161

0

-R: List the ACLs of all files and directories recursively.

-s: Skip files that only have the base ACL entries (owner, group, others).

getfacl -Rs .
getfacl --recursive --skip-base .

Steely Wing

Posted 2012-03-08T14:49:35.537

Reputation: 101

0

I found this googling the opposite; to find files with no ACLs set. This is what I ended up with (in case some other googler finds it)

ls --color=auto -lR | grep -v "\+ " | grep -v "^[.,a-z,1-9]" | grep -v "^$"

Apparently ls -R is faster than find (I have a kagillion files and each find command is taking me 2 hours).

matiu

Posted 2012-03-08T14:49:35.537

Reputation: 208