The Hidden Files in Your Linux Home Directory, Explained


Key Takeaways

  • Hidden files in Linux begin with a period and, by default, file managers do not show them.
  • Many apps clutter your home directory with hidden files, but the XDG Base Directory Specification offers a solution.
  • You can use xdg-ninja to clean up hidden files in your home, but be cautious and only move or delete files you understand.



Hidden files are a useful built-in feature of Linux that helps to keep your system organized. But older or poorly behaved apps can clutter your home directory with many unnecessary files. Find out how to deal with the mess.


What Are Hidden Files?

On Linux—and similar OSes, like macOS—a hidden file is simply a file whose name begins with a period (.) character. You might also know them as “dotfiles.”

By default, your file manager—Nautilus, Thunar, etc.—will not show hidden files, and they do not appear via a standard ls in the terminal. Nautilus lets you view these files via a menu option:

Nautilus file manager with a menu option to show hidden files

Meanwhile, the terminal command ls -a will show hidden files alongside others:


A list of files in a terminal, many of which are hidden files whose name begins with a period.

You can use hidden files for whatever you want, but they work best for configuration and apps will usually manage these files for you. You’ll only really need to work with them when you’re searching for a specific hidden file—to check a log or manually alter some config, for example.

Why Do So Many Hidden Files Live in My Home?

Many apps save user-specific data to files directly in your home directory (~/). This approach dates right back to the early days of UNIX, with files like .bashrc and .profile. Following UNIX tradition, these are simple text files that you can edit to change settings that your system uses when it starts up.


Command-line apps like vim will often create dotfiles in your home. This .viminfo file, for example, stores metadata like your command history:

The contents of a .vimimfo file with a section for command line history

It’s not just command-line apps, either. GIMP, Firefox, and Inkscape are all prone to dropping dotfiles in your home directory, even though better alternatives are available.

Hidden files aren’t too much of a problem, but having a lot of them in your home directory can be distracting. You may prefer a less cluttered home, especially when you’re looking for a specific hidden file or copying a directory. Fortunately, there’s a solution.


What Are the Alternatives?

First, if you don’t use the command line much, or you’re simply not bothered about too many files in your home, you’re free to ignore them or hide them altogether. However, if you’re willing to take the time, you can address the situation instead.

The XDG Base Directory Specification aims to solve this problem, and many apps and distros have adopted it as a common standard. Instead of storing tens or even hundreds of hidden files in your home directory, the XDG spec proposes a single hidden directory in your home: .local/.

The hierarchy of a .local folder with subfolders under share for specific applications

Inside .local, you may find directories with familiar names like share and bin. These mimic their equivalents in global locations—like the root of your filesystem—so share should contain data files and bin should contain executables.


Aside from organizing everything in one place, this approach also uses non-hidden files underneath .local. This can make it more convenient to work with such files or version-control them.

Can I Fix Up My Home?

Do not delete—or even move—any files unless you understand their purpose. Hidden files are more likely to be vital for your system to run correctly. However, with practice and experience, you’ll learn which files are safe to edit.

Not all apps are well-behaved and, if you’ve been running your Linux system for a few years, you’ve probably built up a pile of hidden files in your home directory. So, what to do with them? If you’d like to clean things up, an app called xdg-ninja can help. This simple shell script will look for unwanted files and directories in your home and advise you where to move them if there’s a cleaner alternative.


You’ll need to be comfortable with the command line to use xdg-ninja, but you’re free to use any of its recommendations you like, ignoring any you’re unsure about. To use it:

  1. Install the script, either manually or using your favorite package manager.
  2. Run xdg-ninja.sh.
  3. You’ll see a list of recommendations like the following. Make sure you understand each suggestion, then follow the steps to move the file out of your home directory.

Sample output from xdg-ninja with suggestions to move a .fontconfig file and migrate a .gnupg file

With a deeper understanding of your Linux system, you may even be able to move or delete unwanted dotfiles by hand. You should still exercise caution, and keep backups, but the freedom to keep things clean and organized may prove productive—or simply offer peace of mind.




Source link

Previous articleThe iPhone 16 event surprises that left me frustrated