Using the "find" command to look for multiple UID's


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Using the "find" command to look for multiple UID's
# 1  
Old 03-26-2013
Using the "find" command to look for multiple UID's

I have a security audit requirement to produce a list of files that a specific list users have access to. In other words, I'm trying to use find to search files which user1 owns OR user2 owns OR user3 owns, and so on. Can this be done on one command line or do I need to use a for loop and just loop through the user list? I was trying to do something like:

Code:
find ./* -user bob -user jane

Which of course, does not work. Perhaps I need to try a different angle. Any suggestions on using find in this way or an alternative method would be greatly appreciated.
# 2  
Old 03-26-2013
try find ./* \( -user bob -o -user jane \) -print
# 3  
Old 03-26-2013
find ./* is redundant. find recurses, so find . is sufficient.

Find takes the -o option for or, and lets you group with ( ). You must quote them so the shell doesn't do silly things like try and put those as commands in a subshell.

Code:
find . '(' -user bob -o -user jane ')'

# 4  
Old 03-26-2013
I thought I had done that before. I remember now. Thanks y'all.

Of all the things I've lost I miss my mind the most.

---------- Post updated at 11:33 AM ---------- Previous update was at 11:25 AM ----------

How about if I want to search on a range of UID's? For example:

uid > 100 && uid < 500
# 5  
Old 03-26-2013
If the find implementations that you will use support -uid [+-]n, then that's trivial.

Regards,
Alister
# 6  
Old 03-26-2013
Quote:
Originally Posted by westmoreland
I have a security audit requirement to produce a list of files that a specific list users have access to. In other words, I'm trying to use find to search files which user1 owns OR user2 owns OR user3 owns, and so on. Can this be done on one command line or do I need to use a for loop and just loop through the user list? I was trying to do something like:

Code:
find ./* -user bob -user jane

Which of course, does not work. Perhaps I need to try a different angle. Any suggestions on using find in this way or an alternative method would be greatly appreciated.
What kind of access? (Read access? Write access? Execute access? Read and write access?) Having access to a file and being a file's owner are two VERY different things. A file with mode 777 can be accessed by every user on your system that can read or search the directory in which that file resides.

The find commands proposed so far in this thread do not in any way, shape, or form determine which files can be read, written, executed, or searched by any given user.
# 7  
Old 03-26-2013
Fine question Don. And good point. In this case, I believe the auditor is looking to see exactly what the permission bits are set to for files with specific users and groups (haven't included that part yet). Ultimately, I think he actually wants to see the ACL's (if any) associated with those particular files.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

find . -path "*_nobackup*" -prune -iname "*.PDF" \( ! -name "*_nobackup.*" \)

These three finds worked as expected: $ find . -iname "*.PDF" $ find . -iname "*.PDF" \( ! -name "*_nobackup.*" \) $ find . -path "*_nobackup*" -prune -iname "*.PDF" They all returned the match: ./folder/file.pdf :b: This find returned no matches: $ find . -path "*_nobackup*" -prune... (3 Replies)
Discussion started by: wolfv
3 Replies

2. Shell Programming and Scripting

Using "Find" & Storing To Multiple Variables

Hello all! I'm pretty new to bash scripting, so this should be a pretty easy question to solve. For the last few hours, I've been creating a script that will list some of the following (based on a path I specify): # of directories # of files # of executable files files older than 365... (2 Replies)
Discussion started by: alphekka
2 Replies

3. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

4. AIX

How to use 'expect' to pass UID & Password to a "for loop" in shell script?

Friends, Need someone's help in helping me with the below requirement for a script: > For a list of servers(over 100+), I need to login into each of them(cannot configure password-less ssh) & grab few configuration details < I know, this is possible through expect programming in a simple... (2 Replies)
Discussion started by: thisissouvik
2 Replies

5. Shell Programming and Scripting

Find lines with "A" then change "E" to "X" same line

I have a bunch of random character lines like ABCEDFG. I want to find all lines with "A" and then change any "E" to "X" in the same line. ALL lines with "A" will have an "X" somewhere in it. I have tried sed awk and vi editor. I get close, not quite there. I know someone has already solved this... (10 Replies)
Discussion started by: nightwatchrenba
10 Replies

6. Shell Programming and Scripting

Find out if multiple files have lines ending with"r"

I am trying to find out which files in a group of files have lines ending in r. What I have is this: cat /tmp/*RECORDS| if grep r$>/dev/null; then echo "yes";else echo"no";fi Records is more than one file. There are the following files TEST-RECORDS /volume/testing /volume/programs ... (2 Replies)
Discussion started by: newbie2010
2 Replies

7. Shell Programming and Scripting

Using a single "find" cmd to search for multiple file types and output individual files

Hi All, I am new here but I have a scripting question that I can't seem to figure out with the "find" cmd. What I am trying to do is to only have to run a single find cmd parsing the directories and output the different file types to induvidual files and I have been running into problems.... (3 Replies)
Discussion started by: swaters
3 Replies

8. Shell Programming and Scripting

Problem with "find" and "grep" command

I want to list all files/lines which except those which contain the pattern ' /proc/' OR ' /sys/' (mind the leading blank). In a first approach I coded: find / -exec ls -ld {} | grep -v ' /proc/| /sys/' \; > /tmp/list.txt But this doesn't work. I got an error (under Ubuntu): grep:... (5 Replies)
Discussion started by: pstein
5 Replies

9. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

10. Shell Programming and Scripting

"find command" to find the files in the current directories but not in the "subdir"

Dear friends, please tell me how to find the files which are existing in the current directory, but it sholud not search in the sub directories.. it is like this, current directory contains file1, file2, file3, dir1, dir2 and dir1 conatins file4, file5 and dir2 contains file6,... (9 Replies)
Discussion started by: swamymns
9 Replies
Login or Register to Ask a Question