1822146 Members
4318 Online
109640 Solutions
New Discussion юеВ

Find File Permissions

 
SOLVED
Go to solution

Find File Permissions

Hi, I am wanting to find all directories and files within a directory structure that do not have universal write access. I know that { find [filename] -perm -2 -print } will find all with universal write access, but just can't work out how to change it to those without universal access. Any help on this would be greatly appreciated. Thanks
10 REPLIES 10
RAC_1
Honored Contributor

Re: Find File Permissions

For files
find /dir -type f !\( -perm 0002 -o ! -perm 002 ) -exec ll -d {} \;

For dirs
find /dir -type d \( ! -perm 0002 -o ! -perm 002 \) -exec ll -d {} \;
There is no substitute to HARDWORK
Arunvijai_4
Honored Contributor

Re: Find File Permissions

Hello,

You can ! with find

# find /dir -type f !\( -perm 0002 -o ! -perm 002 ) -exec ls -l {} \;

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
Peter Godron
Honored Contributor

Re: Find File Permissions

Hi,
the "!" is the logical not.
So reversing your find condition should get you the data.

find . ! -perm -2
Muthukumar_5
Honored Contributor

Re: Find File Permissions

Simply as,

# find . \( -type d -o -type f \) ! -perm -002

--
Muthu
Easy to suggest when don't know about the problem!

Re: Find File Permissions

Maybe that is not exactly what I am wanting to find out. I think what I really want to know is which files are unable to be writen to by the user I am logged in as. So if I am admin what files am I unable to modify.

Cheers
Arunvijai_4
Honored Contributor

Re: Find File Permissions

Hello,

If you are an "admin", you can modify any files in the system.

Login as the user, and try to run find with ! for that user with write permission.

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
Muthukumar_5
Honored Contributor

Re: Find File Permissions

Use -user -group with ! to find files or directories which are not related to that user for writing.

--
Muthu
Easy to suggest when don't know about the problem!

Re: Find File Permissions

If that is the case why does it keep saying access denied? I know you can modify anything as the "su" user but I have not got that access.

Cheers
Yogeeraj_1
Honored Contributor
Solution

Re: Find File Permissions

hi,

find is trying to check all the files and directories as per instruction.

Unless you are root user or equivalent, you will always get these messages.


have you looked into SUDO?

hope this helps!

kind regards
yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
Arturo Galbiati
Esteemed Contributor

Re: Find File Permissions

Hi
you can use this to look for file non writer by the user you are logged:

for FilNam in $(find . -type f 2>/dev/null) ;do
if [[ ! -w $FilNam ]]; then
echo file $FilNam not writeable
fi
done

HTH,
Art