1

I want to write a shell script that will show me which users home directories are world readable so I can easily see directories I have access to. I was trying to figure out how to do this. If anyone could point me in the right direction it would be appreciated!

Whoppa
  • 949
  • 3
  • 13
  • 23
  • 1
    For system commands like this, you might have better luck over at SuperUser.SE –  Sep 29 '13 at 07:41
  • You may try `find` with `perm` option, and ask on SuperUser if you still have problem. – leesei Sep 29 '13 at 07:55

3 Answers3

5

You can use find -perm like this:

find /base/path -type d -perm +o+r

+o+r will only list directories with word (others) read bit on.

anubhava
  • 761,203
  • 64
  • 569
  • 643
0

have you checked this

find /dir/to/search -type f -exec sh -c 'file -b {} | grep text &>/dev/null' \; -print

From Finding human-readable files on unix

Community
  • 1
  • 1
Sunil Verma
  • 2,490
  • 1
  • 14
  • 15
-2

Use this command

ll /path/to/your/dirextory/ | grep ^d......r..

This will give you the directories will everyone has permission to read.

Ben
  • 51,770
  • 36
  • 127
  • 149
mukh007
  • 339
  • 1
  • 6
  • 17
  • -1 `ll` is not a standard command, and parsing the output of `ls` is poor practice. – tripleee Sep 29 '13 at 07:53
  • @triplee, I agree that `ll` ia not a standard command, but `ls` is described in the POSIX specification, so don't see why parsing its output would be poor practice, as long as it is done correctly (which is not the case here) – Scrutinizer Sep 29 '13 at 09:09
  • 1
    @Scrutinizer http://mywiki.wooledge.org/ParsingLs – tripleee Sep 29 '13 at 13:19
  • @tripleee: Thanks for the link and pointing out that file names can contain newline characters! I have never come across a file name with newlines, so for command line work, one can probably get away with it, but for production shell scripts, that is a different matter, I agree.. – Scrutinizer Feb 11 '14 at 17:46