How to find 777 permisson is there or not for Directories and sub-directories

Hi All,

I am Oracle Apps Tech guy, I have a requirement to find 777 permission is there or not for all Folders and Sub-folders
Under APPL_TOP (Folder/directory) with below conditions
i) the directory names should start with xx..... (like xxau,xxcfi,xxcca...etc)
and exclude the directory name if xxk...
ii)If any directory or Sub-directory do not have 777 permission it should print in a file.

Below is the sample structure in UNIX.
/appl_top/ls
au ap po ax xla xlp xxau xxcca xxcfi xxkin .....

under xxcfi there are some sub folders like
/appl_top/xxcfi/11.5.0>ls
admin bin log sql.........

please Don't mind if I am not posted exact what am asking, but my main aim is to list all Folders and Sub-folder which are not having 777 permissions.

Thanks in Advance.

find /appl_top -type d -name "xx*" -a ! -name "xxk*" | xargs -i find '{}' ! -perm 777

Further to bartus11, in one pass.

find /appl_top -type d \( -name "xx*" -a ! -name "xxk*" -a ! -perm 777 \) -print

A bit of an unusual request. One would think it would be of interest to find all the directories that are 777 so that they can be corrected and secured...

I think gagan4599 wants to print also subdirectories below "xx*" directories that have names other than "xx*", and your code finds only those starting with "xx".

@bartus11
Seems ambiguous whether conditions i) and ii) are additive. Needs an example.
Let's see what O/P says.

Hi methyl,

bartus11 is correct under APPL_TOP i have directories like
au
po
xa
xpil
xxau
xxcfi
xxkin
xxcca
etc...

here i want only directories which are starting with "xx..." and it should not include "xxk..." directory.
after this there are some sub-directories these will not start with "xx..."

if I execute 'ls' command under "xxcfi" top list of sub-directories like below
ex: /appl_top/xxcfi/ls

     admin 
     sql 
     bin
     forms  .... etc

note: any sub-directory name will not start with "xx.."

I need to execute the Unix command under APPL_TOP only.

When I execute command

find /appl_top -type d -name "xx*" -a ! -name "xxk*" | xargs -i find '{}' ! -perm 777

at different level am getting error please find below

qtcdev:/apps/qtcdev/appl_top> ! -name "xxk*" | xargs -i find '{}' ! -perm 777<
find: /appl_top: No such file or directory
qtcdev:/apps/qtcdev/appl_top>cd ..
qtcdev:/apps/qtcdev>" | xargs -i find '{}' ! -perm 777                       <
find: /appl_top: No such file or directory
qtcdev:/apps/qtcdev>

Thanks Guys for ur support.

If you want only directories and subdirectories to be found use:

find /appl_top -type d -name "xx*" -a ! -name "xxk*" | xargs -i find '{}' -type d ! -perm 777

Hi Bartus11,
Thank you for your quick response,

I need to execute the Unix command under APPL_TOP only.
when i executed below commands

(find /appl_top -type d -name "xx*" -a ! -name "xxk*" | xargs -i find '{}' ! -perm 777)  # and
(find /appl_top -type d -name "xx*" -a ! -name "xxk*" | xargs -i find '{}' -type d ! -perm 777)

at different level am getting error please find below

qtcdev:/apps/qtcdev/appl_top> ! -name "xxk*" | xargs -i find '{}' ! -perm 777<
find: /appl_top: No such file or directory
qtcdev:/apps/qtcdev/appl_top>cd ..
qtcdev:/apps/qtcdev>" | xargs -i find '{}' ! -perm 777                       <
find: /appl_top: No such file or directory
qtcdev:/apps/qtcdev>

I assume "/apps/qtcdev/appl_top" is your APPL_TOP? Then use:

find /apps/qtcdev/appl_top -type d -name "xx*" -a ! -name "xxk*" | xargs -i find '{}' -type d ! -perm 777

Path to search always comes first in "find"

1 Like

Thanks a lot bartus, the above command is fulfilling my requirement but when i execute i got below output

qtcdv:/apps/qtcdv/appl_top>find /apps/qtcdv/appl_top -type d -name "xx*" -a ! -name "xxk*" | xargs -i find '{}' -type d ! -perm 777
find: /apps/qtcdv/appl_top/izu/11.5.0/bin/out: Permission denied
find: /apps/qtcdv/appl_top/izu/11.5.0/bin/rda/output: Permission denied
/apps/qtcdv/appl_top/xxcca/11.5.0/test
/apps/qtcdv/appl_top/xxcca/11.5.0/test/sample
qtcdv:/apps/qtcdv/appl_top>

As per the command it has to search only Directories which are starting with "xx..." but i got result above, here the "izu" directory should not come rite cause its not starting with "xx..."
Really I am very thankful for your support.

I think it is just error from stat on directory that has restricted access. Try that to avoid that:

find /apps/qtcdev/appl_top -maxdepth 1 -type d -name "xx*" -a ! -name "xxk*" 2>/dev/null | xargs -i find '{}' -type d ! -perm 777