Sometimes, it can be useful to hide some file or folder from the default view in a file manager. Unlike Windows, Linux uses a completely different method to make a file or folder hidden. You won't find a "hidden" attribute in file properties or anywhere in the GUI. Let's see how it can be done in Linux. I use Linux Mint with MATE, but the method described in this article is applicable to any distro, any Desktop Environment, and any file manager.
There are two methods to hide a file or folder. I will review them both.
Historically, Linux considers files and folders as hidden if their name starts with a dot. For example, if a folder is named .SomeHiddenFolder, it won't be displayed anywhere!
So, the first method to hide a file or folder from the default view in Linux is to just rename the target object beginning with a period character. Here is how.
To hide files and folders in Linux, do the following.
- Open a file manager of your choice. It can be Thunar in XFCE, Caja in MATE, Nemo in Cinnamon, or the console app Midnight Commander - anything you like.
- Navigate to the file or folder you want to hide.
- Rename it by adding a dot "." to the beginning of the name of the object.
That's it. It will be hidden. The GUI file manager won't display it by default:
Even the console ls won't list it.
To toggle visibility of hidden objects, press CTRL+H in your GUI file manager (CTRL+. in Midnight Commander).
In the terminal, execute the command ls -a to see hidden objects.
That's it! Pretty easy, right? However, renaming files and folders may not be a convenient method. I don't like touching file names just to hide them. Thankfully, there is an alternative method, which, however, works only with GUI file managers.
How to Hide Files and Folders in GUI apps
Open a file manager of your choice and navigate to the folder which contains the objects you want to hide.
There, create a new text file called .hidden. It will be parsed by GUI file managers.
On each line of the file, type the name of the file or folder you want to hide, one item per row. See the following screenshot.
Save the file and re-open the folder. The objects listed in the ".hidden" file will disappear!
The console ls command still shows them, so this method affects only GUI apps.
Windows has a number of ways to hide files. These include the classic console command, attrib, from the DOS era and the Properties dialog. Newer graphical tools come by default with Windows 10 to quickly hide or unhide files. You can see all the ways to hide files in Windows in this article: How to hide and unhide files quickly in Windows 10