#HeyNerds, why are #Unix #permissions 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 directory permissions might make more sense if you think of a directory as holding a list of files. You need read permission to read the list, write permission to modify the list and access permission to access the list of files.

See this website to see if this helps explains directory permissions [ hackinglinuxexposed.com/articl ].

@sohkamyung And exec permissions? Why are they required for everything else that's actually going to be of use? And why do write permissions require exec, what's the point of that?

I feel like this will only make sense once I understand more about how the filesystem is implemented.

Follow

@JordiGH @sohkamyung The regular execute permission isn't meaningful for directories, so that bit was repurposed as "permission to access paths below this directory." One use case is letting users access their own home directory without letting them get the full list of dirs under /home by setting only the exec bit. It may seem weird, but it makes some sense in the context of early Unix systems.

Sign in to participate in the conversation
Society of Trolls

A nice little Mastodon instance. Mild trolling encouraged (keep it local), but not required. Malicious behaviour is not tolerated. Follow Wheaton's law and you'll be fine.