, why are so weird for directories?

Read perms let you list the filenames in the directory but nothing else (e.g.. not contents of files nor metadata like size or file owners).

Write perms let you add/delete/rename files in that directory, but only if exec perms are also present.

Exec perms let you read or write to files that already exist in a directory, but not list the names nor change the names. Hope you already know the filename you're after.

... WHY??

@JordiGH The exec part is because there are executables that everyone should be able to execute, but they don't need to see what is available. You want almost everyone to be able to use what is in /bin, but you don't want anything else above their home folder to be accessible to them. It is easier to keep track of what is going on if you say 'everyone gets exec permissions on /bin' and leave it at that.

I don't know about the other two.

@inmysocks Hm, but how can the shell search your PATH if there are no read permissions for part of it? The shell can't list names, ohhhh, right, why list when you can just grab the requested executable and append it to each part of the PATH in turn to see if it would work.

Okay, but why do exec permissions also let you write to files if you already know their names?

@JordiGH I am not sure about the second part. One thing to remember is that system processes have unlimited access for the most part, it is only your commands that are limited. So if you execute a file and the file writes to something it may not be using your permissions to determine if it is possible.

If exec permissions let you write to files directly than I have no idea, that doesn't really make sense.


@inmysocks You also need the file's write permissions to be set, but the directory's exec permissions are also required to write to that file.

I am thinking of trying to figure out how inodes were originally implemented to see if I can find the underlying reason.

Sign in to participate in the conversation

A Mastodon instance for maths people. The kind of people who make \(\pi z^2 \times a\) jokes. Use \( and \) for inline LaTeX, and \[ and \] for display mode.