Looking for Linux file, then checking for 755 attributes

Yet another in the recent tasks that I’ve been looking to create decent analysis for.

So, for this part of things I’m looking for existence of specific file.

If the file is found, then need to look to see if the has the right permissions/attributes (755)

Given what I’m looking for, I suppose my best approach is to pull back True or False for existence of the file (so I’ll be able to tell easily what part of this test has failed just by looking at my results check list), then use another returned property to see if the file mode is correct.

For now, I had this as my analysis properties check/relevance:

/* assume file exists, if file doesn't exist, then obviously going to get back "false" (or error??) */
(mode of file "/path/file.sh" as string as lowercase = "-rwxr-xr-x")

I’d rather be checking to see if mode = 755, but I got an error message of a different type when trying that?!


This is an example of checking for the existence of an object, with an additional criteria/filter. As such, we can use ‘exists’ and ‘whose’ in a syntax such as the following:

exists file "file.sh" whose (mode of it as string = "-rwxr-xr-x") of folder "/path"

Thanks again @Aram I’ll give that a try. The one thing that worries me a bit is that there are may or may not be some sticky bit flags on some of the files. That leads me back to thinking that I should probably be looking for the mode numerically versus converting to string and looking to compare that.



exists file "file.sh" whose (mode of it as octal string = "0755") of folder "/path" *** Edited for accuracy to include the leading “0”.

see here for more information about properties of mode: https://developer.bigfix.com/relevance/reference/mode.html


Thanks very much for the additional tip. I think that may have knocked this out completely for me. Much appreciated!! (And will mark as completed if so)

Thank gawd for persistence and testing (breaking things up a little in my analysis).

I know the file that I’m looking for exists, but… I’m not seeing any places where the file is showing the right mode. Probably just an issue with the mode not being what my Linux SA was thinking it was supposed to be.

Anyway, will continue to tweak and get that part right, but pretty sure that testing that I’m doing in the analysis is correct now.

Got this one fixed. Needed quick confirmation from the Linux SA. The mode I needed to check for was ‘0755’, not simply 755.

Updating that took care of knocking this one done completely. Thanks much, learned a lot and have some great examples for similar tasks in the future. Much appreciated all!