Home Configuration Files – Understanding Locations: ~/, ~/.config/, ~/.local/share/

configurationhome

There are a number of hidden configuration files in my home directory:

  • some of them are in ~/ (e.g. ~/.cinnamon)
  • some of them are in ~/.config/ (e.g. ~/.config/cinnamon-session)
  • some of them are in ~/.local/share/ (e.g. ~/.local/share/cinnamon-session)

What is the logic as to where home configuration files live?

a) What is the difference between hidden files in these three places?

b) What exactly does "local" mean in this context, vs config, vs home?

c) In the home directory, are there also other important common configuration directories used by multiple applications?


Debian 8.6
Cinnamon 2.2.16

Best Answer

There's a long history here when it comes to the general case of "dot files", but the $HOME/.config and $HOME/.local directories that you specifically mention have an origin in the XDG Base Directory Specification.

  • $HOME/.config is where per-user configuration files go if there is no $XDG_CONFIG_HOME.
  • $HOME/.cache is where per-user cache files go if there is no $XDG_CACHE_HOME.
  • $HOME/.local/share is where per-user data files go if there is no $XDG_DATA_HOME.

Windows users may recognize this as a parallel of what Microsoft has had in Windows NT since version 4 (albeit that the names changed in version 6.0):

  • %USERPROFILE%/AppData/Local/ a.k.a. %LOCALAPPDATA% — where per-user data files for this machine go
  • %USERPROFILE%/AppData/Roaming/ a.k.a. %APPDATA% — where per-user data files that a roaming user can access from multiple machines go
  • %USERPROFILE%/AppData/Local/Temp/ a.k.a. %TEMP% — where per-user temporary files go

The idea is that per-user files can be (amongst quite a lot of other things) application data files (machine-specific or roaming), application configuration files, cached files, and temporary files, and applications place them in subtrees rooted at these particular directories.

(MacOS has a similar system where users get individual per-user "user local" subtrees under /var/folders with C and T subdirectories for cache and temporary files.)

As the Arch people note, there are some "dot" files and directories that have become commonly used by several applications and are unlikely to agree with XDG in the foreseeable future, such as $HOME/.ssh and $HOME/.netrc .

Further reading

Related Question