18

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?

5 Answers5

22

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'
u1686_grawity
  • 426,297
  • 64
  • 894
  • 966
0

Perl version:

getfacl -R -p -s  / | perl -wn -e ' if (/^# file/) { s|^# file: /||; print; }'
Nicola Mingotti
  • 171
  • 1
  • 5
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
  • 101
  • 1
0

How I solved it:

getfacl --recursive --skip-base / 2>/dev/null | grep "file:" | cut -d" " -f3 | awk '{print "/"$1}'

returns:

/dev/snd/seq
/dev/snd/timer
/dev/dri/card0
mgutt
  • 858
  • 1
  • 14
  • 29
-1

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
  • 266
  • 2
  • 9