Operating System - HP-UX
1850486 Members
2769 Online
104054 Solutions
New Discussion

Re: check for world readable

 
SOLVED
Go to solution
Shabu Khan-2
Frequent Advisor

check for world readable


Folks,
This might be an easy one, I guess I just couldn't think today ...

I am looking for a shell built-in like an umask or a command like chmod or -r switch to check if a file is world readable programmatically

How do I go about doing it? I don't want to ls -l the file and cut the last three bits and then check if it has an 'r' or a 'w' or an 'x' but looking for something in-built, I thought there is something available to validate if a particular file is world readable?

Thoughts?

for .e.g
ls -l /var/cron/log
make sure this is world readable

Thanks,
6 REPLIES 6
Tim Nelson
Honored Contributor

Re: check for world readable

find / -local -perm -006

or something close to this.

Shabu Khan-2
Frequent Advisor

Re: check for world readable

The Problem with the find solution is that it cannot only specifically check the 'others' bit, I'll have to say what the owner/group bits are set to which I don't want to assume.

Any other method?
Shabu Khan-2
Frequent Advisor

Re: check for world readable

The Problem with the find solution is that it cannot only specifically check the 'others' bit, I'll have to say what the owner/group bits are set to which I don't want to assume.

Any other method?

Thanks,
Shabu
James R. Ferguson
Acclaimed Contributor
Solution

Re: check for world readable

Hi:

To search a directory for all world-readable files:

# find /path -type f -perm -o+r

If you wanted either world-readable OR world-writable, do:

# find /path -type f \( -perm -o+r -o -perm -o+w \)

Regards!

...JRF...
Tim Nelson
Honored Contributor

Re: check for world readable

then there is

find ./ -perm -002

will find all files with perms write for other.

Shabu Khan-2
Frequent Advisor

Re: check for world readable

Thanks JRF and others who responded!