LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How can I prevent a user from seeing a file in a directory listing? (https://www.linuxquestions.org/questions/linux-newbie-8/how-can-i-prevent-a-user-from-seeing-a-file-in-a-directory-listing-878543/)

nuspieds 05-03-2011 07:38 AM

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.

Thanks!

AlucardZero 05-03-2011 08:15 AM

It's not possible. Move the files into a folder that does not give any permissions to 'other' (nor 'group' if you want too).

never say never 05-03-2011 09:59 AM

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.

For an understanding of hiding files (not for security) http://www.felgall.com/lincmd5.htm

For a better understanding of permissions check out http://www.zzee.com/solutions/linux-permissions.shtml

also refer to man chown and man chmod

nuspieds 05-03-2011 11:32 AM

Quote:

Originally Posted by AlucardZero (Post 4345033)
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. :)

Thanks!

nuspieds 05-03-2011 11:38 AM

Quote:

Originally Posted by never say never (Post 4345136)
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.


All times are GMT -5. The time now is 06:03 PM.