0

Does execution of a file need read permission? It is natural to think yes, because execution of a file needs to load the file into memory. If the answer is no, why is that?

In particular, same question when the file is a directory?

Thanks.

2

When you execute a file, in many cases you don’t need to read it, so you don’t need read permission. You’re right, the system needs to read it on your behalf, but that’s not defined as requiring the read permission (because nothing running as you ever needs access to the file’s contents).

The exception is any circumstance where executing a file involves reading it, by a process running with your credentials. So shell scripts, in fact scripts in general, require read permission, as would any executable handled by binfmt_misc.

Likewise, accessing a directory doesn’t involve reading it: you can enter a directory without listing its contents. Think of this as exploring a building with a blindfold: execute/search permission allows you to unlock doors to change rooms (as long as you already know where the doors are), read permission allows you to remove the blindfold to see what’s in the room.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.