How to hide or show hidden files and folders on Ubuntu Linux
Hidden files and folders are those files/folders on Linux that are by default hidden from normal view in the File Manager.
They are commonly used to store configuration information and kept hidden simply to prevent accidental deletion or editing.
A well-known example of a hidden file is the .htaccess file which is used for modifying and storing configuration details on an apache server.
When a file/folder is hidden, it remains in its current location, only that it becomes invisible in the file manager's normal view. You aren't able to see these files just by browsing through the file manager.
Besides their common use in configuration files, you can also use them to hide private information on your PC. For instance, if you share your PC with your family members, friends, or work colleagues, you may want to hide certain private files and folders.
In this article, you will learn how to create, hide and show hidden files and folders on your Ubuntu Linux PC using GUI and terminal.
How to make hidden files and folders
Using Ubuntu, you can easily hide and unhide your files and folders on the file manager.
All you need to do is just add a dot (.) at the beginning of a file's or folder's name. Hidden files are also referred to as dotfiles due to their names starting with a dot.
For instance, if you have a folder with the name "My Folder", you can simply rename it by adding a dot at the beginning so that the new name will be ".My Folder". It automatically becomes a hidden file and invisible from the file manager's normal view.
The same case applies to files. If for instance, you have a file with the name "Assignment.pdf", you can hide it by changing its name to ".Assignment.pdf".
Renaming a file/folder is simple, just right-click on it and select the rename option. Alternatively, click on the file then press the F2 key on the keyboard.
After renaming the file, it may continue being visible. In such a case you may have to refresh your file manager window or move out of it then open it again for the file to be hidden from view.
How to hide files and folders without renaming them
For some reason, you may want to make some files and folders hidden without necessarily having to rename them to start with a dot. Yes, that's possible!
All you need to do is create a text file and name it ".hidden". In the file, add the names of files and folders that you want to hide. Each file/folder name should be on its own line. The names should be exactly the same as on the files' names, with the same case and extensions (for files).
It is important to note that this method works only for files and folders in the same directory with the .hidden file. It doesn’t work for nested directories. You can create many .hidden files on different directories to hide files in them.
How to show hidden files and folders
You can view the files hidden from the file manager's normal view in a number of ways:
- Via terminal ls command
- Via keyboard shortcut on File manager
- Via change of settings on File manager
1. Via terminal ls command
On Linux, the ls terminal command is used to show a list of files and folders in a given directory.
The command above shows a list of all the normal files and folders in the home directory. You can use the cd command and a directory path to change to your preferred directory.
Now to show a list of all the files and folders in a directory, inclusive of the hidden ones, you need to add the -a flag to the ls command as shown below.
Now you can see that with the change of command above, we have a larger list of files. Those that were hidden earlier have their names starting with a dot.
2. Via keyboard shortcut on File manager
Below is the screenshot of the file manager home directory.
To show the hidden files in this directory, simply press the keyboard shortcut Ctrl + H. It refreshes the window and shows the previously hidden files and folders as shown below.
This will as well show hidden files on all the other directories in the file manager.
If you would want to hide the hidden files again, simply press the same Ctrl + H shortcut again and they will disappear from the normal view.
3. Via change of settings on File manager
Another way to show the hidden files is to click on the menu (3 horizontal lines) icon at the top-right of the file manager. Then check/tick the "Show Hidden Files" checkbox. This refreshes the window, showing the previously hidden files and folders.
This will show hidden files even in all the other directories in the file manager.
To hide the hidden files again using this method, just uncheck the checkbox and they will disappear.
If for some reason you want to change the files from being hidden files back to normal files/folders, simply rename them and remove the dot at the beginning of their names.
That's all for this article!
Now you know what hidden files are on Linux, how to create them, and how to show or hide them using different methods.