Hide Directories and Files With and Without Renaming Them on Linux

Hiding Files And Folders On Linux

There might be several files and folders which you want to hide from your Terminal and GUI File Manager, they could be cluttering your interface (such as your dotfiles) or you may not want others to find those files you are hiding. You can simply add . (dot) at the beginning of the folder or file which you want to hide.

In your file manager, you can view these hidden objects by pressing the Ctrl+H key on your keyboard.

Linux-based operating systems, by default, also have tons of operating systems which include your config files and other directories which are required by different applications. They are hidden because they are of no use to you, and you should not delete/modify them (unless you know what you are doing).

Let’s see how can we create a hidden file on Linux from the GUI file manager first.

Creating Hidden Objects From the GUI File Manager

Open your file manager and select the object you want to hide. Right-click on it and select the rename option, or just press the F2 key on your keyboard. Now, just add a dot (.) in front of the file/folder name and press enter. Sometimes this does not work immediately, so just hit refresh (F5 key) once if it does not hide it for you.

You can press Ctrl+H or right-click and then select view hidden files.

VIewing Hidden Files From The GUI
Viewing Hidden Files From The GUI

To hide the files again, press Ctrl+H again.

Hiding Objects From the Terminal

If you use the Terminal more often than the GUI, you might want to learn this trick to work from the Terminal as well. Just rename the file or directory as you would normally do, and add a (.) dot before the filename. For example :

mv filename .filename
Hiding Files From The Terminal
Hiding Files From The Terminal

To view hidden files from the Terminal, just use the -a option with the ls command, like this :

ls -a

Hide Directories and Files Without Renaming Them

This method only hides directories and files in the GUI and does not hide anything from the ls command in the terminal. It can be useful to hide several directories which are used by the system (such as snap directories) but, if renamed, cannot be utilized by the system’s resources.

What we have to do is, create a file named .hidden in the same directory where you want to hide your stuff, and in that .hidden file, we will add the names of the objects we want to hide in different lines. Note that it does not support absolute or relative paths, so you have to put the .hidden file where all your stuff is.

Hide Files And Directories Without Renaming Them
Hiding directories and files Without Renaming Them

As you can see, the content of .hidden file is file3 and dir2, and they do not show up in the Nemo file manager, despite being present in the output of ls command. You can again press Ctrl+H to view the hidden files and folders in your file manager.


The ‘adding (.) before your filename to hide a file’ feature was introduced as a bug in the UNIX-based systems. A single dot was used to signify the current directory and (..) used to signify the parent directory. They did not contain any data in them, and the ls command ignored them and any other filename starting with (.). The -a option was then added to the ls command to show the hidden objects.

Note that if you have any important data which you do not want others to look at, it’s better to encrypt them rather than hide them.