How can I prevent a user from seeing a file in a directory listing?
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
How can I prevent a user from seeing a file in a directory listing?
Hi,
I hope that I am posting this in the right forum.
I have, for example, a folder called "MyFolder" and it contains 3 files: MyFile1, MyFile2, MyFile3. The only file that I do NOT want a particular user/group to even see that it exists is, for exmple, MyFile2.
So, when they do a directory listing on MyFolder, they should only see MyFile1 and MyFile3. How can this be done in Linux? The important thing is that it is not just preventing them from "executing" MyFile2, but to prevent them from even knowing that it exists by not including it in a directory listing.
This is a simpified example using one file, but in reality, I have lots of files and some of those that I want to block are also subfolders.
It is very important for me to hide the existence of certain files/folders when the user does a directory listing. It's also important that the files stay in their current folder (that is, I can't use a workaround which requires moving all the files into a separate folder and then securing that folder).
Please let me know if this is possible and if so, how.
Well you can make the file hidden, (in linux files that start with a period are hidden) but that will not prevent someone from listing hidden files, and you can set permissions on the file to prevent certain groups for opening or executing the file. But you can't just make it like it doesn't exist.
It's not possible. Move the files into a folder that does not give any permissions to 'other' (nor 'group' if you want too).
Ok, thanks for the clarification.
Moving the files into another folder is the last thing I wanted to do becuause I hate splitting up my content. I'd much prefer to create whatever organizational structure I wanted and then secure it accordingly. But, hey, since it's no possible, then I'll just have to manage somehow.
Well you can make the file hidden, (in linux files that start with a period are hidden) but that will not prevent someone from listing hidden files, and you can set permissions on the file to prevent certain groups for opening or executing the file. But you can't just make it like it doesn't exist.
Now that just might work! I'll have to test it and see, but the access is via a Media Center unit I have (as opposed to via another computer or command-line access). So as long as the Media Center unit does the equivalent of a regular "ls" without the parameter to also display hidden files, then I should get the results I'm looking for.
Thanks for the idea and the reference links! I'll do the test when I get home and let you know if it worked.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.