Hidden files are files that are, well, hidden. Here’s how to find and view them on Linux-based Operating Systems.
Hidden files are hidden from view by default unless otherwise specified.
Why would you want some files to be hidden? Usually, they are configuration files. You don’t really need to see them during your day-to-day tasks; they’d just clutter things up and get in the way.
Your home directory, which includes all of your user files, has several hidden files and folders in it. These include temporary files, your shell configuration, a place for your web browser to store temporary files. Things that you will rarely if ever, need to navigate.
Having them hidden means that it’s easier to navigate the files and folders you do use day-to-day – your Documents, Downloads, Desktop folders. Your text documents and music. Stuff that you actually use.
Hidden files Are Not a Security Measure
First up, hiding a file is not a security measure. It just hides it from the view by default. It doesn’t hide it from other users; it just means you have to use a slightly different command so that hidden files are visible when needed. So don’t hide files as a security measure.
Creating Hidden Files
First up, how to create a hidden file. It’s easy – you just add a . (period) to the beginning of the file name.
Here’s a file that isn’t hidden
Renaming it with the mv command:
mv myFile.txt .myFile.txt
… Now it’s hidden. You can confirm this by running the ls command to list files:
You won’t see it, of course, because it’s hidden.
Showing Hidden Files
Showing hidden files is about as easy as hiding them – here’s how it’s done.
In the Linux Shell/Terminal
The ls command has the -a option, which can be specified to view all files – including hidden files. Just run:
…for a list of all files in the current directory – hidden or not.
You can view the hidden files in a different directory by supplying the directory path to the ls command:
ls -a /path/to/directory
In the GUI
If you’re working in a GUI such as Gnome or KDE, you can usually use a keyboard shortcut to toggle showing hidden files in the file browser.
In Gnome, this keyboard shortcut is the combination:
CTRL + H
…If you’re using a different environment, you may need to check the documentation or check the available drop-down menus to find out what shortcut to use.