[plug] Listing all files / directories accessible by specific user account

Jeremy Kerr jk at ozlabs.org
Wed Jun 26 02:04:50 UTC 2013


Hi Alex,

> I am trying to find the best way to list all files and directories
> which are accessible by a specific user. So far the best option I
> found was:
> 
> sudo -u <useraccount> find / -readable -print 2>&1 |grep -v
> "Permission denied" sudo -u <useraccount> find / -writable -print
> 2>&1 |grep -v "Permission denied" sudo -u <useraccount> find /
> -executable -print 2>&1 |grep -v "Permission denied"
> 
> However I wonder if there is a better way of doing this.

I'd say you're pretty close, just a couple of improvements:

 * you're combining stdout and stderr, but then grepping-out all
   of the stuff that will appear on stderr. I'd say just discarding
   stderr would be cleaner

 * you can combine multiple tests with -o ("or").

so:

sudo -u <useraccount> \
    find / -readable -o -writeable -o executable -print 2>/dev/null

Cheers,


Jeremy


More information about the plug mailing list