Score:1

Is it possible to make a directory that a user cannot list, but would be able to access files in it?

ls flag

Is it possible to make a directory that a user cannot list, but would be able to access files in it?

Provide examples of when this might be necessary.

David avatar
cn flag
No it is not and how would they know the file name? Reads like homework suggest you do your own homework.
pLumo avatar
in flag
@David, that is actually not correct. You could run some software that serves the files, but does not allow listing. Such as a webserver does usually. However, the question should be focused to an actual problem, and not some theoretical question.
hr flag
With normal Unix file permissions, unsetting the read bit on the directory will prevent its contents from being listed. See for example [Execute vs Read bit. How do directory permissions in Linux work?](https://unix.stackexchange.com/a/526315/65304)
Bruni avatar
cn flag
See also here: https://stackoverflow.com/questions/46190151/in-linux-how-do-i-set-permissions-for-a-directory-that-prevent-a-user-from-listi
cn flag
"Provide examples of when this might be necessary." sorry? why would we need to do that?
Score:4
cn flag

Yes indeed. You can see the contents of the directory if the read r permission is set. You can traverse a directory and retrieve a file from it if the x permission is set.

Examples where that may be necessary? Any time you want to give users access to a specific folder, but do not want they can inspect the contents of the parent directories. For example, if you do not want that users can see the name of the home directory of other users in /hom, then you could turn off the r bit of /home for "others".

It is never "necessary". It is always the administrator that balances security needs and implements them. There can only be recommendations here, and these will depend on each individual use case.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.