I was wondering if there is any way that you can make a folder invisible or inaccessible under Linux.

PS. I don't mean in unaccessible that you can't access it because you don't have the privileges. I mean when you try to access it, it tells you something like "Directory or file does not exist" even though you do have the access privileges to access

  • 5
    Sure, unmount its partition.
    – Kusalananda
    Jul 10, 2018 at 10:47
  • 1
    maybe something like this is possible with selinux but I really don't know how this works.
    – Kiwy
    Jul 10, 2018 at 12:09
  • 2
    So you want the directory to exist, you want to have permissions to read it. But you want to not be able to read it, and you want the error message to say “File does not exist”. Am I correct? Jul 10, 2018 at 13:12

2 Answers 2


you can hide it from normal ls but a couple of arguments would show it, just like 'hidden' file in windows. if just in case you missed this.

just as @kusalananda said, you could unmount the partition on it, but then it is a problem if the volume in question can't be unmounted, you could create a small separate partition for this job and then mount/unmount it.


short answer is you can't.

let's assume we both have root access to a host.

  • How could you have an automatic setup that allow you to access file and forbid me ?
  • Every command you use, I can use them (even if you delete .history).
  • You can crypt file/folder, but at a time you must uncrypt it, and I could/will read it.
  • Same goes with unmounting a device (even a crypted filesystem, see above point).

-- This is hardly an answer, so I wrote as a wiki.

  • actually the main reason of this question is for security issue ,i am curious that is it possible someone make a file or directory that include malware and we could not find it with any method.
    – R1w
    Jul 11, 2018 at 7:00
  • 1
    looks like a cops and thieves games, neither side have an absolute and automatic way to discover (cops) or hide (thieves) files.
    – Archemar
    Jul 11, 2018 at 7:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.