How to hide files from any file manager on Linux desktop
Want to hide files and folders from your Linux desktop file manager? Jack Wallen shows you a practical method.
You are probably already familiar with the traditional method of hiding files on the Linux command line. Otherwise, any file starting with a. will not be seen with the ls command unless you add the -a option. These same files and directories will be hidden from the file manager unless you explicitly tell the file manager to show these secreted files.
It’s a convenient way to hide sensitive information (such as app configurations, etc.) away from prying eyes. While it’s not really a means of security, it shouldn’t be overlooked as an added layer.
SEE: Windows 10 Security: A Guide for Business Owners (TechRepublic Premium)
But did you know that there is another way to hide files and directories from desktop file managers – one that hides standard directories out of sight, without having to add one. in the name of the directory? This can be useful for directories that already exist and you cannot change their names (like the ~ / snap directory).
There are two caveats to this method. The first is that it behaves similarly to the norm. phone book. In other words, you can reveal these hidden files and directories in the same way. For example, with Nautilus file manager, press Ctrl + h key combination to hide or reveal hidden files / directories. The second downside is that it doesn’t work with the command line. So even if Nautilus does not reveal these hidden files, the ls command will, even without the -a option.
Even so, it is still a very convenient method of hiding files and directories.
Let me show you how.
What you will need
The only thing you will need for this to work is a running Linux instance with a desktop. You should also have files and directories to hide (but that’s obvious).
How to hide files and directories from file manager
Let’s say you have three directories and two files to hide from the file manager. These directories are:
The files to hide are:
To hide these files and directories from the file manager, create a new file with the command:
In this file, you would add the following:
snap code-server PYTHON somefile.txt license.xml
Save and close the file.
Close your file manager and reopen it. You should no longer be able to see these files unless you ask the file manager to reveal the hidden files.
If you want to hide folders outside of your home directory, you need to create a .hidden file at the root of the folder you want to hide. For example, if you are hiding directories or files in the root directory, run the command:
sudo nano /.hidden
Suppose, for example, that you want to hide the / opt folder. For this you need to create a .hidden file in / with the content:
Save and close the file, restart your file manager, and the / opt directory will no longer appear.
While this is not a foolproof way to hide files (because anyone who knows how to reveal hidden files and folders in File Manager can easily reveal them), it is an easy method to hide any file or directory. on your system.
Editor’s Note: This article has been corrected by the author to include the sudo nano /.hidden command.