0

I have a folder which I want to hide, but not by prepending a dot, because then you just need to enable "View hidden folders" in the file manager. I don't want that - I want it to be REALLY hidden, so that it does not appear neither in the file manager (I'm using Thunar, if it matters) nor in the output of ls. It should be still accessible by it's name, though (else I could just delete it). Example:

~$ ls -a
folder_to_be_hidden
some_other_folder
~$ some_thing_to_hide_a_folder_or_file folder_to_be_hidden
Successfully hidden folder_to_be_hidden !
~$ ls -a
some_other_folder
~$ ls some_other_folder
some_file
another_file
~$

Is this possible at all ? I'm using Ubuntu Studio 20.04, if that matters.

P.S.: I need this to hide some folders from being found when someone else accesses my machine over SSH, that's why it's not enough for them to be hidden in the file manager ! They also should not be able to see that I'm hiding the files from them. At the same time, for those who know about the files / folders (me), they should be still accessible by just putting their path.

TheEagle
  • 143
  • Hello. It is not a built in feature of Ubuntu OS. Did you try a Google search? – David Mar 31 '22 at 15:20
  • 2
    You can encrypt a directory, which will pretty much do what you're asking. If something is encrypted, it cannot be accessed by anyone without authorisation. – matigo Mar 31 '22 at 15:46
  • @David: yes, but all I got were questions and answers about prepending a dot to the filenames or pressing Ctrl+H in the filemanager, which both don't do what I need. – TheEagle Mar 31 '22 at 15:51
  • @matigo: hmm, that would be an option … but really, I need it to not appear in the directory listing at all. – TheEagle Mar 31 '22 at 15:51
  • 1
    This is what nested directories are for. Encrypt ~/Mine, and store your banking details in ~/Mine/banking. I guarantee, nobody will see your banking details. – matigo Mar 31 '22 at 15:53
  • 1
    " want it to be REALLY hidden, so that it does not appear neither in the file manager" Nope. Someone with admin/root access will always be able to see it (that includes booting into a live session). Making it inaccessible sure. But not invisible. The EASIEST fix for your problem is not putting the files on the disk at all. An encrypted USB stick that requires a password seems the more logical choice here. – Rinzwind Mar 31 '22 at 16:33
  • USB seems like the best option to me too, + try giving it a name that's so boring no one will ever want to click on it, e.g. "twilight fanfiction" – Rabbit Mar 31 '22 at 17:31
  • No! Anyone with r (read) access to the parent directory can easily see the "hidden" file. – waltinator Mar 31 '22 at 17:36
  • I don't know if this little trick with work with Thunar, but with Nautilus, create a text file named .hidden in your home directory, and then add files/folders names that you wish to hide, to the .hidden text file. – heynnema Mar 31 '22 at 20:20
  • @heynnema problem is, that that won't hide the files when doing an ls in the terminal, right ? – TheEagle Mar 31 '22 at 21:11
  • @Programmer You can try to create a wrapper around the ls command that will remove -a, -A or -f options passed to the command, ie. options that cause files beginning with dot to be shown. However, listing the directory in other way than using ls will still show your "hidden" files. There is no option in Linux to "totally" hide files like you want. – raj Mar 31 '22 at 21:38
  • @Programmer Correct. They'll still show up in ls. Could you just change the folder protection so that "others" doesn't include r/w? – heynnema Mar 31 '22 at 21:53
  • @raj Thanks for clarifying this - knowing it's not possible is at least better than not knowing how to do it ! XD – TheEagle Apr 01 '22 at 00:18

0 Answers0