Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find all files executable by specific user (not current)

Tags:

linux

find

How to find all files which can be executed by specific user (not current!)

For current I can do it like

find /some/start/dir -executable

But now I want to do something like: find all files which user 'josh' can execute (by 'other' permissions, 'user' permissions and 'group' permissions). Of course, I do not know users's 'josh' password so I cannot su'ing.

like image 871
Alex G.P. Avatar asked Oct 10 '22 23:10

Alex G.P.


2 Answers

Look up the user id of "josh" in /etc/passwd.

Then run: find /some/start/dir -type "f" -uid <ID> -perm 111.

like image 176
Ionic Avatar answered Oct 15 '22 11:10

Ionic


I know this is an older thread, but I had to do this recently and it is still relevant.

Since we're talking about *nix permissions, one tedious yet thorough way to approach this is by looking at the membership that the ID has on the system:

ie:

# assuming josh is a member of group "grpname"

find / -user josh -perm -100     # gets files owned by josh & are executable
find / -group grpname -perm -010 # gets files with grp ownership and executable
                                 #        via group 
                                 #     Must be repeated for each group josh is in
find / -perm -001                # gets files executable by any user

Note there could be some overlap for files that josh owns but are also owned by group "grpname". A sort|uniq would filter those out pretty easily.

like image 41
Tim S. Avatar answered Oct 15 '22 10:10

Tim S.