Anchor(faq87)

How can I get the permissions of a file without parsing ls -l output?

There are several potential ways, most of which are system-specific. They also depend on precisely why you want the permissions.

The majority of the cases where you might ask this question -- such as I want to find any files with the setuid bit set -- can be answered by the information in [:UsingFind#permissions:]. As the page name implies, those answers are based on the find(1) command.

For some questions, such as I want to make sure this file has 0644 permissions, you don't actually need to check what the permissions are. You can just use chmod 0644 myfile and set them directly.

If your needs aren't met by any of those, then we can look at a few alternatives: