Yes, there is a standard: these are specified by freedesktop.org and are part of XDG Base Directory Specifications.
config-spec outlines just basic requirements, but the details are in the Base Directory Specifications. The ~/.config
and ~/.cache
directories are default unless configured otherwise:
There is a set of preference ordered base directories relative to which configuration files should be searched. This set of directories is defined by the environment variable $XDG_CONFIG_DIRS.
There is a single base directory relative to which user-specific non-essential (cached) data should be written. This directory is defined by the environment variable $XDG_CACHE_HOME.
...
$XDG_CONFIG_HOME defines the base directory relative to which user specific configuration files should be stored. If $XDG_CONFIG_HOME is either not set or empty, a default equal to $HOME/.config should be used.
...
$XDG_CACHE_HOME defines the base directory relative to which user specific non-essential data files should be stored. If $XDG_CACHE_HOME is either not set or empty, a default equal to $HOME/.cache should be used.
You may notice these specifications mostly state where data should be stored, which environment variables used, and in what manner ( desktop-neutral, efficient, etc ), but most desktops are free in implementing the "how" part of it. The GNOME-based desktops will use gsettings
where as KDE users can use the same via kwriteconfig
, but they both will rely on ~/.config
directory in the process
Question key points
How do I know this is an officially supported folder and not just a flavor of the month location for a per-user cache/config?
These directories appear in official documentation and Filesystem Hierarchy Standard also mentions them. This is official documentation, hence the folders are officially supported.
Is this something I should just accept as an un-stated standard practice location?
Depends on the app you're creating. Is the app supposed to be configurable on per-user basis or work consistently through out the system ? FHS tells us that for system-wide stuff we should use /etc
or /usr/local
, but XDG directories should be used for user-specific configurations - ~/.cache
and ~/.config
. Of course, if application isn't dependent on user-specific settings, /var/cache can be used instead of per-user directory. Of course, you could always have single ~/.appname.conf
file, a ~/.appname.db
or ~/.appname/
directory to keep configurations and cache there, but that would be non-standard; not "bad" - just non-standard.
See also
ls
would ignore dot files and other applications sort of adopted it, but they're in no way hidden, and shouldn't be used as security feature in any way. Rob Pike, one of the Unix wizzards, has also clarified that originally the purpose was to hide.
and..
directories from the output, but that was implemented in a wrong fashion. Read about it here: askubuntu.com/a/1073810/295286find
command or Python for example - these don't ignore dotfiles by default. I agree that it may be convenient to remove them from listing to the end-user, but that's about it..
. Are they totally invisible? No, and they shouldn't be. Can they still be read/written? Yes, and they should. Are they invisible (hidden) in most cases? Yes -- that's the point