root owned files/world writable
Gary Weimer
weimer at ssd.kodak.com
Fri Nov 16 03:25:59 AEST 1990
In article <1990Nov14.224701.15657 at cs.odu.edu> epperly at cs.odu.edu (William "Badger" Epperly) writes:
>
[trying to find world-writeable files owned by root. following doesn't work]
>
>find / -user root -ls | awk {'if substr($1,9,1)=w print>test.out
first, syntax for awk is wrong, you want something like:
awk ' {if (substr($1,9,1) == "w" ) print $8 > "test.out" } '
^ ^ ^ ^^ ^ ^ ^ ^^ ^ ^ ^ ^
1 2 3 4 5 5 3 6 5 5 2 1
1) a single quote needs to surround the <format> of awk
2) currly brackets are also needed for <format>
3) if stmt's condition needs to be surrounded by parens (sp?)
4) equallity is tested using double =
5) all text must be enclosed in quotes, or it is assumed to be a variable
6) you may or may not want to add this to get only the file name
second, find's -ls does not produce the same output as 'ls -al'. It
produces something like:
9601 1 drwxr-xr-x 3 weimer staff 512 Nov 13 11:42 file_name
so the command you want to use would be:
find / -user root -ls | awk '{if (substr($3,9,1)=="w") print $11 > "test.out"}'
Hope this helps.
P.S. you might also want to find file owned by root that are group writeable
and are part of some universal group (like 'user').
Gary Weimer
More information about the Comp.unix.questions
mailing list