Want to hide files and folders from your Linux desktop file manager? Jack Wallen shows you one handy method.
You probably already know the traditional method of hiding files on the Linux command line. If not, any file that begins with a . will not be seen with the ls command, unless you add the -a option. Those same files and directories will be hidden from the file manager unless you explicitly tell the file manager to show those secreted files.
This is a handy way to hide sensitive information (such as app configurations and the like) away from prying eyes. Although not truly a means to security, it shouldn't be overlooked as an additional layer.
SEE: Windows 10 security: A guide for business leaders (TechRepublic Premium)
But, did you know there's another method to hide files and directories from desktop file managers--one that makes it such that you can hide standard directories away from sight, without having to prepend a . to the directory name? This can come in handy for directories that already exist, and you cannot change their names (such as the ~/snap directory).
There are two caveats to this method. The first is that it behaves in similar fashion to the standard . directory. In other words, you can reveal those hidden files and directories in the same way. For instance, with the Nautilus file manager, hit the Ctrl+h key combination to hide or reveal hidden files/directories. The second caveat is that it doesn't work with the command line. So even though Nautilus might not reveal those hidden files, the ls command will--even without the -a option.
Even so, this is still a very handy method of hiding files and directories.
Let me show you how.
What you'll need
The only thing you'll need to make this work is a running instance of Linux with a desktop. You also should have some files and directories to hide (but that's a given).
How to hide files and directories from the file manager
Let's say you have three directories and two files to hide from the file manager. Those directories are:
The files to be hidden are:
To hide these files and directories from the file manager, create a new file with the command:
In that file you would add the following:
snap code-server PYTHON somefile.txt license.xml
Save and close the file.
Close out your file manager and re-open it. You should no longer be able to see those files unless you instruct the file manager to reveal hidden files.
If you want to hide folders outside of your home directory, you have to create a .hidden file in the root of the folder to be hidden. For example, if you're hiding directories or files in the root directory, issue the command:
sudo nano /.hidden
Say, for example, you want to hide the /opt folder. For that you'd create a .hidden file in / with the contents:
Save and close the file, restart your file manager, and the /opt directory will no longer appear.
Although this isn't a foolproof way to hide files (as anyone who knows how to reveal hidden files and folders in the file manager can easily reveal them) it's an easy method to hide any file or directory on your system.
How to become a cybersecurity pro: A cheat sheet (TechRepublic)
Mastermind con man behind Catch Me If You Can talks cybersecurity (TechRepublic download)
5 best Linux desktop distributions (TechRepublic)
Cybersecurity and cyberwar: More must-read coverage (TechRepublic on Flipboard)
Editor's note: This article was corrected by the author to include the sudo nano /.hidden command.