Solved

used find command with -perm switch to find files where ugo does not have x execute permissions

Posted on 2004-10-01
21
381 Views
Last Modified: 2010-04-21
Hi Guys,
Is it possible and how does on use the find command with -perm switch to find all files where neither the user, group or other has (x) execute permissions.


Cheers


B Cunney
0
Comment
Question by:Barry Cunney
  • 12
  • 9
21 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 12206706
! -perm +111
! -perm +ugo+x
0
 
LVL 17

Author Comment

by:Barry Cunney
ID: 12217745
Hi Ozo,
No that does not work - I understand what you are illuding to though
.... but I am trying to find all files where ugo does NOT have execute permissions


Cheers


 
0
 
LVL 17

Author Comment

by:Barry Cunney
ID: 12217929
I did the following test:
$ ls -l
-rwxrw-r-- 1 barry users 4 Oct 4 16:30 file1
-rw-rw-r-- 1 barry users 4 Oct 4 16:31 file2
-rw-rw-r-x 1 barry users 6 Oct 4 16:31 file3
$ find . -type f \! -perm -0111 -print
./file1
./file2
./file3
$ find . -type f ! -perm -0111 -print
./file1
./file2
./file3

As you can see all three files are returned no matter which way I type the find command

Only 'file2' should be returned because this is the only file where u+g+o do NOT have (x) execute permissions

I only want to find files where all three 'groups' do not have execute permissions.
I am not interested in whether all or any groups have read or write permissions - I am only interested in the (x) execute section for each group

Cheers
0
 
LVL 84

Expert Comment

by:ozo
ID: 12222291
I think I said +111 not -111
0
 
LVL 17

Author Comment

by:Barry Cunney
ID: 12224777
H Ozo,
I tried this and it doesn't work:
$ find . -type f ! -perm +111 -print

Message returned:
UX:find: ERROR: bad permissions: +111


Cheers
0
 
LVL 84

Expert Comment

by:ozo
ID: 12225004
What version of find/unix are you using?
0
 
LVL 17

Author Comment

by:Barry Cunney
ID: 12225651
Hi Ozo,
Version of Unix: SCO Unix - Unixware 7.1.1

What is the best way to establish the version of find command I have?


Cheers
0
 
LVL 17

Author Comment

by:Barry Cunney
ID: 12225670
Ho Ozo,
The date of the 'find' file in bin directory is Oct 12 1999 and the size is 15484


Cheers
0
 
LVL 84

Accepted Solution

by:
ozo earned 50 total points
ID: 12225948
I do not have access to SCO Unix to test this, but try:
! \( -perm -1 -or -perm -10 -or -perm -100 \)
0
 
LVL 17

Author Comment

by:Barry Cunney
ID: 12226123
Hi Ozo,
This is the return from that - I am just double-checking the syntax but I think I have it like you suggested

$ find . -type f !\(-perm -1 -or -perm -10 -or -perm -100\) -print
UX:find: ERROR: Illegal option -- !(-perm
UX:find: TO FIX: Usage: find [path-list] [predicate-list]
$


Cheers
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 84

Expert Comment

by:ozo
ID: 12226212
Space between !  \( -perm and -100 \)
0
 
LVL 17

Author Comment

by:Barry Cunney
ID: 12226251
Hi Ozo,
Again I  might  get you to check if I have syntax right
$ find . -type f ! \(-perm -1 -or -perm -10 -or -perm -100 \) -print
UX:find: ERROR: Illegal option -- (-perm
UX:find: TO FIX: Usage: find [path-list] [predicate-list]
$

Cheers
0
 
LVL 17

Author Comment

by:Barry Cunney
ID: 12226270
Hi Ozo
I put a space in after the first opening bracket in case this was affecting anything - result below
$ find . ! \( -perm -1 -or -perm -10 -or -perm -100 \) -print
UX:find: ERROR: Illegal option -- -or
UX:find: TO FIX: Usage: find [path-list] [predicate-list]
$
0
 
LVL 84

Expert Comment

by:ozo
ID: 12226282
You're still missing a space between \( and -perm
0
 
LVL 17

Author Comment

by:Barry Cunney
ID: 12226320
Hi Ozo,
Forgot to mention that I tried this leaving out -type switch in previous attemt but also tried it with it in
$ find . -type f ! \( -perm -1 -or -perm -10 -or -perm -100 \) -print
UX:find: ERROR: Illegal option -- -or
UX:find: TO FIX: Usage: find [path-list] [predicate-list]
$
0
 
LVL 84

Expert Comment

by:ozo
ID: 12226329
Ok, can you post your `man find` page
0
 
LVL 84

Expert Comment

by:ozo
ID: 12226347
-or might be -o
0
 
LVL 17

Author Comment

by:Barry Cunney
ID: 12226386
Hi Ozo,
You are THE MAN!

$ find . -type f ! \( -perm -1 -o -perm -10 -o -perm -100 \) -print
./file2
./x
$ ls -l
total 6
-rwxrw-r--    1 barry    users             4 Oct  4 16:30 file1
-rw-rw-r--    1 barry    users             4 Oct  4 16:31 file2
-rw-rw-r-x    1 barry    users             6 Oct  4 16:31 file3
-rw-rw-r--    1 barry    users             0 Oct  4 18:28 x
$

looks like success to me - just double checking

Cheers
0
 
LVL 17

Author Comment

by:Barry Cunney
ID: 12226413
Hi Ozo,
Could I just get you to fully explain the logic for the bits you pass into each of the -perm switches.
I sort of understand but am a bit hazy


Cheers
0
 
LVL 84

Expert Comment

by:ozo
ID: 12226500
100 is u+x
10 is g+x
1 is o+x
0
 
LVL 17

Author Comment

by:Barry Cunney
ID: 12226543
Hi Ozo,
I was hoping there was something fancy one could do -    +111 is if x bit was set on for u+g+o
I thought there might be some clever way to bitwise NOT this 111 to come up with a single value we could pass into -perm switch to indicated we only wanted  to find files where the u+g+o did NOT have xecute permissions

but your solution does the job anyway - it's a good solution

Cheers
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now