You are probably familiar with the concept of “hiding” a folder or file in Windows. Hiding a folder or file just “removes” the folder from the normal view and then you can choose to display “hidden files” to see it.
So how do you see the hidden files in Linux then? Let me show you that.
Show hidden files in Ubuntu & other Linux distributions
If you are in a terminal, you can use the ls command to display the all the files, including the hidden ones:
You can recognize the hidden files and folders with the dot (.) before their names.
You can also use the -A option of ls command to show hidden files but without the . and .. files:
If you use desktop Linux, you can still see hidden files easily. Let’s see how.
Keyboard Shortcut in GUI
If you are not a fan of keyboard shortcuts, you can use the file manager GUI to display the hidden folders and files.
To see a hidden file or hidden folder in Ubuntu, go to the file manager (the default is Nautilus). File Manager is Ubuntu’s counterpart of Windows Explorer.
Now go to the top menu->Show hidden files:
How to hide files or folders in Ubuntu
Now that you have learned to see hidden files in Ubuntu, let’s now see how you can hide files and folders in Linux.
Unfortunately/interestingly, there is no similar way as in Windows to hide a folder. In Windows, you right-click on a file and choose the option of making it hidden. But this option is not available in Ubuntu.
So, how can you hide a folder in Ubuntu then? Very simple! Using the Linux property of hiding a file/folder. In Linux, if a file name starts with . (dot), it is considered a hidden file.
Now if you want to hide a file or folder, let’s say MyFolder, just rename it to .MyFolder and it will be taken as a hidden file or folder.
I hope you know how to rename files in Linux command line using mv command.
mv MyFolder .MyFolder
If you are using Linux desktop, just right click and choose the rename option and add the dot before the name.
Bonus Tip: Hiding multiple files and folders without renaming all of them (valid for GUI only)
This is a neat little trick that will let you hide several files and folders from the normal view in your desktop Linux’s file manager.
Traditionally, if you create a .hidden file and add the name of the folders in this file, those folders will be hidden from normal view when you close your file manager and open it again.
Keep in mind that this trick works with only the current directory you are in. It won’t work for nested directories. You can create the .hidden file in any directory to hide files and folders in it.
This was about hiding files in Linux. There are separate methods for locking a folder in Linux. I hope you like this little bit of Linux knowledge.