If you’re new to the world of Linux, you’ve probably encountered the term “hidden files” quite often. But why are they actually? Are they secrets, mistakes, or just forgotten relics of the system? Well, it’s none of the above. In fact, as you will see below, they are something quite simple.
In this article, we’ll unravel the mystery of hidden files in Linux. We’ll cover what they are, how to find them, and why you shouldn’t just delete them all willy-nilly (seriously, don’t do that) because they perform important functions – otherwise, they wouldn’t be hidden, would they?
What Are Hidden Files in Linux?
Hidden files in Linux (commonly referred to as dotfiles) are exactly the same thing as regular files, except for one small difference: their names start with a dot (.). That’s it! For example, a file named “.example.txt” is considered hidden, while a file called “example.txt” is not.
In other words, these aren’t special magic files—they’re just like any other file on your system, except for their hidden nature.
The next big question is: Why are they hidden? Believe it or not, the answer is surprisingly simple—it’s all about reducing clutter.
Most hidden files store configuration data, preferences, or settings for applications and the operating system you don’t interact with daily. For example:
- “.ssh” is where your SSH keys and configurations live.
- The “.bashrc” file contains settings for your Bash shell.
- “.config” holds configuration data for various applications.
In most cases (though not all), their content isn’t meant to be directly edited by the user—unless they’re sure what they’re doing. Instead, it’s typically updated behind the scenes by various applications or the operating system itself.
Keeping them hidden minimizes the risk of accidental changes or deletions, which could cause problems if something important gets deleted or modified.
Lastly, something you’ll want to remember crystal clear—hidden files in Linux do not inherently provide any security benefits because their “hidden” status is merely a naming convention.
Files or directories that start with a dot (.) are simply excluded from the default ls
command output and GUI file manager views. However, this doesn’t prevent anyone from finding or accessing them.
Therefore, always use proper security measures such as file permissions, encryption, or restricted access for true security.
How to List Hidden Files?
Listing hidden files is super easy. In the terminal, add the “-a” option, responsible for showing all files, including hidden files and directories, to the well-known ls -l
command, which, as we know, lists the contents of a directory in a long format.
ls -la
Code language: Bash (bash)
And just like that, the magic happens. This tiny dot at the beginning of a file or folder name signals to Linux that this file (or directory) should be “invisible” by default.
Wait, did I say directory? Don’t worry! The same rules apply—everything I mentioned about hidden files also goes for hidden directories, with no exceptions.
In other words, they follow the same rule: any directory prefixed with a dot (.) at the beginning of its name is considered hidden in Linux. It is just a folder that Linux prefers to keep out of sight by default – there’s nothing unique or different about it compared to other “visible” directories.
For example, in your home directory, you might see these hidden directories if you reveal them:
- .config
- .local
- .cache
Just like hidden files, these directories are used to store configuration files, user preferences, or cache data for applications and the operating system.
Here’s a neat little trick: if you want to list only the hidden files and directories in the current directory, here’s how you can do it:
ls -ld .?*
Code language: Bash (bash)
And now, let me show you how to view all the hidden files and directories using your desktop environment’s file manager. Whether you’re using GNOME’s Files, KDE’s Dolphin, or any other file manager, most of them use the same shortcut: Ctrl + H. Just press that, and you’ll be able to toggle hidden files and directories on or off easily.
Here’s how the file manager displays the contents of the user’s directory by default:
And here’s what happens when you press “Ctrl + H“: all hidden files and directories become visible. To hide them again, press the shortcut once more.
The find command is also a powerful tool for searching files; you can use it to locate hidden files specifically. The example below searches for all files and directories in the current directory, starting with a dot (.) – as we already know, the hidden files convention.
find . -name ".*"
Code language: Bash (bash)
Creating a Hidden File in Linux
The simplest way to create a hidden file is by adding a dot (.) at the beginning of the file name when you create it.
touch .myhiddenfile
Code language: Bash (bash)
For directories, the approach works the same way. Again, it’s all about following the naming convention: just add a dot before the name.
mkdir .myhiddendir
Code language: Bash (bash)
Finally, if you already have a file that you want to hide, simply rename it to start with a dot.
mv myfile .myfile
Code language: Bash (bash)
Wrapping It Up
Hidden files in Linux play an important role in keeping your system organized. Now that you know what they are, go ahead and put this knowledge to good use in your Linux workflow.
The key thing to remember about hidden files is that they’re just regular files with a special naming convention—their names always start with a dot. And while the term “hidden” might suggest some level of security, these files don’t provide any.
So, next time you press “Ctrl + H” or type ls -la
, you’ll know exactly what’s happening. Thanks for your time, and happy exploring!