Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!newstop!sun!amdcad!dgcad!dg-rtp!hunt From: hunt@dg-rtp.rtp.dg.com (Greg Hunt) Newsgroups: comp.unix.questions Subject: Re: root owned files/world writable Message-ID: <1990Nov16.182150.2480@dg-rtp.dg.com> Date: 16 Nov 90 18:21:50 GMT References: <1990Nov14.224701.15657@cs.odu.edu> Sender: usenet@dg-rtp.dg.com (Usenet Administration) Reply-To: hunt@dg-rtp.rtp.dg.com Distribution: na Organization: Data General Corp., Research Triangle Park, NC Lines: 44 In article <1990Nov14.224701.15657@cs.odu.edu>, epperly@cs.odu.edu (William "Badger" Epperly) writes: > > Hey, folks! If this is the wrong place for this article > you have my apologies, but where else would it go? > This is the right place. Ask away! > > Listen, I have a problem here. I am trying to write > a small shell script that will search a network, made up of nine > servers, for all files owned by root that have world writeable > permissions. I have tried working with the find command and its > -perm option but it does not seem to take wild cards (although the > man page shows an example using * and ?, but these only appear to > be for filenames), so that is unusable by itself. It isn't easy (unfortunately) to figure out how to do more complex things like this with find. My find allows me to do this: find / \( -user root -perm -2 \) -print to find files owned by root that also have world write permission. To get find to do the "and" of two conditions, you need to put them next to each other and within a set of parentheses. Since ( and ) have special meaning to the shell, they have to be escaped, so you put a \ in front of them. Putting a - in front of the permission value says "only look at the bits I specify instead of looking at the whole permission value". So the '-2' makes it look for files with the world write bit turned on, and makes it ignore all the other permission bits regardless of whether they are on or off. Give this a try on your system. There's no guarantee, however, that your version of find supports doing things this way. Enjoy! -- Greg Hunt Internet: hunt@dg-rtp.rtp.dg.com DG/UX Kernel Development UUCP: {world}!mcnc!rti!dg-rtp!hunt Data General Corporation Research Triangle Park, NC These opinions are mine, not DG's.